Can't pylint detect unresolved attribute reference? - pylint

We've been bit multiple times that pylint did not catch a simple unresolved attribute reference error.
I looked at pylint code but could not immediately find it. IDE like PyCharm can detect it, so it must be possible to detect it in pylint. We are using pylint as a CI job and want to be able to detect this before we merge code.
What pylint settings do I need to enable to catch an error like below?
class A():
df test_a(self):
print("A")
a = A()
a.test_b() # this should be caught by pylint.

What version of pylint are you using ? Both pylint 2.8.2 and mypy 0.812 detect this problem.
With b.py:
class A():
def test_a(self):
print("A")
a = A()
a.test_b() # this should be caught by pylint.
pylint b.py:
************* Module b
b.py:2:4: R0201: Method could be a function (no-self-use)
b.py:6:0: E1101: Instance of 'A' has no 'test_b' member; maybe 'test_a'? (no-member)
------------------------------------
Your code has been rated at -2.00/10
mypy b.py:
b.py:6: error: "A" has no attribute "test_b"; maybe "test_a"?
Found 1 error in 1 file (checked 1 source file)

Related

Weird Haskell 'stack' error: "can't load .so/.DLL" "not a writable segment"

I am trying to install ghc-mod so that I can use ide-haskell in Atom.
The instructions say to use stack build ghc-mod. It seems that GHC 8.2+ is not supported by ghc-mod, so I set my resolver to lts-9.21.
When running stack build ghc-mod, I keep getting this error (emphasis mine; not using code formatting because line wrap helps readability):
aeson > : can't load .so/.DLL for: /Users/timoffex/.stack/snapshots/x86_64-osx/db354248ca37308313a93487c93190e1d5b819629b60b38b68871c9a691e52b9/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHStime-locale-compat-0.1.1.3-KZ1jqNx8uhlHjmuPPj6V1Y-ghc8.0.2.dylib (dlopen(/Users/timoffex/.stack/snapshots/x86_64-osx/db354248ca37308313a93487c93190e1d5b819629b60b38b68871c9a691e52b9/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHStime-locale-compat-0.1.1.3-KZ1jqNx8uhlHjmuPPj6V1Y-ghc8.0.2.dylib, 5): REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 2 which is not a writable segment (__LINKEDIT) in /Users/timoffex/.stack/snapshots/x86_64-osx/db354248ca37308313a93487c93190e1d5b819629b60b38b68871c9a691e52b9/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHStime-locale-compat-0.1.1.3-KZ1jqNx8uhlHjmuPPj6V1Y-ghc8.0.2.dylib)
... (later)
-- While building package aeson-1.1.2.0 using:
/Users/timoffex/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build --ghc-options ""
Process exited with code: ExitFailure 1
Progress 1/4
Here's a snippet from the above that looks weird to me:
REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 2 which is not a writable segment
I am running macOS Catalina 10.15.3.
I can't find any mention of this online except for this open GitHub issue: https://github.com/facebook/duckling/issues/446
I also tried lts-7.24. I get the exact same error, except it happens while building profunctors.
What could be the problem? Where can I file a bug?
I had the same error in a project using resolver: lts-9.17.
What fixed it for me is to update stack.yaml and use this line:
resolver: lts-10.9

Xcode watch 'invalid expression'

I'm stepping through some Swift code in Xcode and I'd like to watch values. Following the advice in many of the answers here (e.g. this one) I can add the expression to the local variables window.
The breakpoint I am on is the last line of this fragment from the Starscream library (by daltoniam) which I include as a pod.
for i in 0..<dataLength {
buffer[offset] = data[i] ^ maskKey[i % MemoryLayout<UInt32>.size]
offset += 1
}
var total = 0
I've added two expressions to watch:
buffer[0] and
MemoryLayout<UInt32>.size
For both the value I see is "invalid expression":
These expressions are clearly are not invalid, if they were the code would have thrown an exception when they were encountered executing the previous few lines. What am I missing? How should I watch and not get 'invalid expression'
N.B. If I call p buffer[0] from the lldb prompt I get the cryptic error:
(lldb) p buffer[0]
error: warning: :12:9: warning: initialization of variable
'$__lldb_error_result' was never used; consider replacing with assignment to '_'
or removing it
var $__lldb_error_result = __lldb_tmp_error
~~~~^~~~~~~~~~~~~~~~~~~~
_
error: :19:5: error: value of type 'WebSocket' has no member
'$__lldb_wrapped_expr_72'
$__lldb_injected_self.$__lldb_wrapped_expr_72(
^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
I have tried changing the podfile (as per Jim's answer) so that it explicitly gets the debug code:
pod 'Starscream', '~> 3.0.6', :configuration => 'Debug'
and I have even gone as far as removing the pods, cloning Starscream, and including the source code as a sub-project. I still get the same error.
An expression that accesses buffer[0] where buffer is a UnsafeMutablePointer works correctly in the expression parser when I'm stopped in some simple function. And from your experience with the expr command directly, it looks like your problem is not with this particular expression. Rather it looks like there's something about the context you are stopped in that's tripping up the expression parser altogether.
Make sure that you aren't using binary cocoapods's and that you've rebuilt all your code and all the pods you are using have been rebuilt from scratch with the same swift compiler. At present, lldb and swiftc are version locked - lldb can only debug programs built with the swiftc that it ships with.
If that doesn't fix the issue, then we'll need to figure out what about the particular function you are stopped in that's causing the problem. This seems like the sort of thing better dealt with by filing a bug with the swift project (http://bugs.swift.org).

I recently create a project of OPNET 14.5 and i have been unable to run the simulation. the error is about Pipeline stage model (dpt_ecc_pon)

I installed OPNET modeler 14.5 at my laptop (OS: Windows 8).
I slightly modified a process model, and ran simulation. But I see the following errors.
<<< Recoverable Error >>>
Pipeline stage model (dpt_ecc_pon) compilation failed
Source code was unavailable to the compiler
----
<<< Recoverable Error >>>
Object repository construction failed
Pipeline stage (dpt_ecc_pon) compilation failed, no source code found.
T (0), EV (-), MOD (NONE)
----
<<< Program Abort >>>
Error encountered rebuilding repository -- unable to proceed
T (0), EV (-), MOD (NONE)
How can i overcome this?
If you create dpt_ecc_pon pipeline stage source, there are some rules to define them. Based on your error message, the dpt_ecc_pon.ps.c/cpp is not included in the model_dirs.
All source code should be included in model_dirs. Press Ctrl+Alt+P. In preference dialog, search 'model_dirs' and make sure the directory where your codes are included in the 'model_dirs'.

Can't get example code on www.scalafx.org to run

I'm trying to get the example code (HelloScalaFX) on http://www.scalafx.org/ to run. However, the line
fill <== when (hover) choose Color.Green
otherwise Color.Red
give me the error
overloaded method value <== with alternatives: (v:
scalafx.beans.value.ObservableValue[_ <:
javafx.scene.paint.Paint, _ <: javafx.scene.paint.Paint])Unit <and> (v:
javafx.beans.value.ObservableValue[_ <: javafx.scene.paint.Paint])Unit cannot be applied to
(scalafx.Includes.ObjectConditionBuilder[javafx.scene.paint.Color])
If I delete the offending lines, I get no compile errors, but running it gives:
Error: Could not find or load main class HelloStageDemo
How do I resolve the overloading and get this to work?
OSX 10.11.5
JavaSE-1.8
Scala IDE build of Eclipse SDK (4.3.0)
Scala Library container 2.11.8
scalafx_2.12.0-M4-8.0.92-R10.jar
Thanks,
Dave
First, there should be no line break before otherwise, that code would not compile in Scala. It should be:
fill <== when (hover) choose Color.Green otherwise Color.Red
There was a break on the http://www.scalafx.org/ due to page layout, it is now corrected.
The second error, "Could not find or load main class", is not ScalaFX or JavaFX related but probably something with your code that you did not include in the question or with Eclipse setup.

Building Cocoon 2.1.0 with JDK 7 fails: compile-build.xml:68

I am using java JDK 7 in my attempt to build cocoon 2.1.10 on Windows 2008 R2 for eventual deployment in Tomcat 7. I have downloaded the cocoon source files, unzipped them, set my JAVA_HOME variable and then tried to run the build.bat file provided. I get 11 different compilation errors.
D:\cocoon-2.1.10-src\cocoon-2.1.10>build.bat
Buildfile: build.xml
prepare:
====================================================================
Apache Cocoon 2.1.10 [1999-2006]
====================================================================
Building with Apache Ant version 1.6.5 compiled on June 2 2005
--------------------------------------------------------------------
Using build file D:\cocoon-2.1.10-src\cocoon-2.1.10\build.xml
--------------------------------------------------------------------
Compiler options:
- debug ......... [on]
- optimize ...... [on]
- deprecation ... [off]
====================================================================
compile-core:
Compiling 594 source files to D:\cocoon-2.1.10-src\cocoon-2.1.10\build\cocoon\classes
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:39: error: package com.
sun.image.codec.jpeg does not exist
import com.sun.image.codec.jpeg.ImageFormatException;
^
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:40: error: package com.
sun.image.codec.jpeg does not exist
import com.sun.image.codec.jpeg.JPEGCodec;
^
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:41: error: package com.
sun.image.codec.jpeg does not exist
import com.sun.image.codec.jpeg.JPEGEncodeParam;
^
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:42: error: package com.
sun.image.codec.jpeg does not exist
import com.sun.image.codec.jpeg.JPEGImageEncoder;
^
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:326: error: cannot find
symbol
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
^
symbol: class JPEGImageEncoder
location: class ImageReader
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:326: error: cannot find
symbol
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
^
symbol: variable JPEGCodec
location: class ImageReader
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:327: error: cannot find
symbol
JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(currentImage);
^
symbol: class JPEGEncodeParam
location: class ImageReader
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:333: error: cannot find
symbol
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bstream);
^
symbol: class JPEGImageEncoder
location: class ImageReader
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:333: error: cannot find
symbol
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bstream);
^
symbol: variable JPEGCodec
location: class ImageReader
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:334: error: cannot find
symbol
JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(currentImage);
^
symbol: class JPEGEncodeParam
location: class ImageReader
D:\cocoon-2.1.10-src\cocoon-2.1.10\src\java\org\apache\cocoon\reading\ImageReader.java:342: error: cannot find
symbol
} catch (ImageFormatException e) {
^
symbol: class ImageFormatException
location: class ImageReader
11 errors
BUILD FAILED
D:\cocoon-2.1.10-src\cocoon-2.1.10\tools\targets\compile-build.xml:68: The following error occurred while exec
uting this line:
D:\cocoon-2.1.10-src\cocoon-2.1.10\tools\targets\compile-build.xml:51: Compile failed; see the compiler error
output for details.
I also tried using "build war" on my command line and this yielded the same result.
Is this an issue with the JDK I am using or is there something else that I need to be looking at? This is my first attempt at building and deploying cocoon, I could be missing something obvious.
Regards, Tony
The deprecated, proprietary com.sun.image.jpeg.codec package has been removed from JDK 7 (see this official official JDK7 compatibility note). Hence your compilation problem.
Since patching the Cocoon source may not be an option in your situation, the shortest path for you might be to compile using JDK 6 (or earlier, the Cocoon 2.1 series require "Java 1.3 or later").
(But if it is, as you seem to require specific Cocoon and JDK versions, you may want to have a look at the SO Q&A on How to replace com.sun.image.codec.jpeg.JPEGImageEncoder with calls to the standard Java Image I/O API)
Another option might be to look at a separate distribution of the com.sun.image.jpeg.codec package to include in you build (and possibly runtime) classpath. I'm unsure about the availability (and the ease of use) of this option. Anyhow I wouldn't recommend digging into it unless all other path have proven to be dead-ends...
In my case the solution for this error was: search for folder endorsed, it should be in path : cocoon-2.1.11-src\cocoon-2.1.11\lib\endorsed
copy this folder in your curren JAVA_HOME/jre/lib
And try to build again.
i hope than this solve your problem
I know this is old but in case anyone's interested I was able to build cocoon 2.1 recently without errors
I had to get the latest source from their current dev branch however (2_1_X) since I found that they'd fixed this bug but it still wasn't in their latest release (2.1.12) yet
I was actually able to build it with JDK 8 and also run it with Tomcat 8. Had to do some tweaks to get that working properly tho

Resources