Flake8 failing to detect syntax issues that can be detect by pyflakes - flake8

I am trying to get Emacs' flycheck to work nicely with python syntax error checking. By default it uses flake8, but I noticed that recently flake8 is only reporting style issues, when it supposed to produce the same kind of results as pyflakes.
As an example, I have a simple python script with a wrong module name.
$ cat so.py
import os
print(os.path)
op.path()
output of $ flake8 so.py is empty, while pyflakes' output is
$ pyflakes so.py
so.py:5: undefined name 'op'
My flake8 configuration, if it matters:
[flake8]
max-line-length = 96
ignore = E123,E701,E126,F821
I am using Linux, if that matters.
Flake8 version: version 3.3.0 mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.5.0
Pyflakes version: 1.5.0

When you're wondering why Flake8 isn't reporting something you think it should, the best path forward is to utilize the --isolated flag.
With the file contents above in ex.py if I do:
❯❯❯ flake8 --isolated ex.py
ex.py:5:1: F821 undefined name 'op'
With that in mind, it does appear that your configuration is the problem here.

Related

How does one install a opam coq package that has been successfully install previously?

I know this has been installed before becuase the proverbot9001 project has used it before. So how do I go about finding what exactly is the issue in my set up that doesn't let me install it? Any install is fine I suppose
(iit_synthesis) brando9~/proverbot9001 $ opam install -y coq-ext-lib
The following actions will be performed:
∗ install coq-ext-lib dev
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved coq-ext-lib.dev (git+https://github.com/coq-community/coq-ext-lib#master)
[ERROR] The compilation of coq-ext-lib.dev failed at "make -j127 theories".
#=== ERROR while compiling coq-ext-lib.dev ====================================#
# context 2.1.3 | linux/x86_64 | ocaml-base-compiler.4.07.1 | https://coq.inria.fr/opam/extra-dev#2022-12-06 09:40
# path ~/.opam/coq-8.10/.opam-switch/build/coq-ext-lib.dev
# command /usr/bin/make -j127 theories
# exit-code 2
# env-file ~/.opam/log/coq-ext-lib-1328047-92e9b2.env
# output-file ~/.opam/log/coq-ext-lib-1328047-92e9b2.out
### output ###
# [...]
# make[2]: *** [Makefile.coq:658: theories/Tactics/BoolTac.vo] Error 1
# make[2]: *** Waiting for unfinished jobs....
# File "./theories/Programming/With.v", line 59, characters 0-39:
# Warning: Declaring a scope implicitly is deprecated; use in advance an
# explicit "Declare Scope struct_scope.". [undeclared-scope,deprecated]
# File "./theories/Data/ListFirstnSkipn.v", line 51, characters 0-101:
# Error: This command does not support this attribute: global.
#
# make[2]: *** [Makefile.coq:658: theories/Data/ListFirstnSkipn.vo] Error 1
# make[1]: *** [Makefile.coq:321: all] Error 2
# make[1]: Leaving directory '/lfs/ampere4/0/brando9/.opam/coq-8.10/.opam-switch/build/coq-ext-lib.dev'
# make: *** [Makefile:7: theories] Error 2
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build coq-ext-lib dev
└─
╶─ No changes have been performed
my set up:
(iit_synthesis) brando9~/proverbot9001 $ opam switch
# switch compiler description
→ coq-8.10 ocaml-base-compiler.4.07.1 coq-8.10
coq-8.12 ocaml-base-compiler.4.07.1 coq-8.12
coq-8.14 ocaml-base-compiler.4.07.1 coq-8.14
ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1 ocaml-variants.4.07.1+flambda ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1
[NOTE] Current switch is set locally through the OPAMSWITCH variable.
The current global system switch is coq-8.14.
(iit_synthesis) brando9~/proverbot9001 $ opam list
# Packages matching: installed
# Name # Installed # Synopsis
base v0.14.0 Full standard library replacement for OCaml
base-bigarray base
base-threads base
base-unix base
cmdliner 1.0.4 Declarative definition of command line interfaces for OCaml
conf-findutils 1 Virtual package relying on findutils
coq 8.10.2 pinned to version 8.10.2
coq-fcsl-pcm 1.2.0 Partial Commutative Monoids
coq-inf-seq-ext dev Coq library for reasoning inductively and coinductively on infinite sequences
coq-int-map 8.10.0 Maps indexed by binary integers : IntMap
coq-mathcomp-algebra 1.11.0 Mathematical Components Library on Algebra
coq-mathcomp-bigenough dev A small library to do epsilon - N reasonning
coq-mathcomp-fingroup 1.11.0 Mathematical Components Library on finite groups
coq-mathcomp-ssreflect 1.11.0 Small Scale Reflection
coq-pocklington dev Pocklington's criterion for primality in Coq
coq-serapi 8.10.0+0.7.2 Serialization library and protocol for machine interaction with the Coq proof assistant
coq-smpl 8.10.2 Smpl: An Extensible Tactic for Coq
coq-struct-tact dev Coq library of structural tactics and utility lemmas about lists and finite types
cppo 1.6.9 Code preprocessor like cpp for OCaml
csexp 1.5.1 Parsing and printing of S-expressions in Canonical form
dune 3.6.1 Fast, portable, and opinionated build system
dune-configurator 3.6.1 Helper library for gathering system configuration
num 1.4 The legacy Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.07.1 The OCaml compiler (virtual package)
ocaml-base-compiler 4.07.1 Official release 4.07.1
ocaml-compiler-libs v0.12.4 OCaml compiler libraries repackaged
ocaml-config 1 OCaml Switch Configuration
ocaml-secondary-compiler 4.08.1-1 OCaml 4.08.1 Secondary Switch Compiler
ocamlfind 1.9.1 A library manager for OCaml
ocamlfind-secondary 1.9.1 Adds support for ocaml-secondary-compiler to ocamlfind
parsexp v0.14.2 S-expression parsing library
ppx_derivers 1.2.1 Shared [##deriving] plugin registry
ppx_deriving 5.2.1 Type-driven code generation for OCaml
ppx_deriving_yojson 3.6.1 JSON codec generator for OCaml
ppx_import 1.9.1 A syntax extension for importing declarations from interface files
ppx_sexp_conv v0.14.3 [##deriving] plugin to generate S-expression conversion functions
ppxlib 0.25.1 Standard library for ppx rewriters
result 1.5 Compatibility Result module
seq base Compatibility package for OCaml's standard iterator type starting from 4.07.
sexplib v0.14.0 Library for serializing OCaml values to and from S-expressions
sexplib0 v0.14.0 Library containing the definition of S-expressions and some base converters
stdlib-shims 0.3.0 Backport some of the new stdlib features to older compiler
yojson 2.0.2 Yojson is an optimized parsing and printing library for the JSON format
related:
https://github.com/coq-community/coq-ext-lib/issues/131
https://github.com/UCSD-PL/proverbot9001/issues/56
coq-ext-lib dev uses the current main branch on github as source for the code. If you go and look there, you will see that the opam file states explicitely that the version of coq for which the sources work go from 8.8 to any 8.9, and then to any version above 8.11. This means that the version 8.10 is explictely ruled out.
Either you have to choose to work with a version of coq that is not 8.10, or you have to choose to work with a numbered version of coq-ext-lib that is compatible with coq-8.10. I suggest coq-ext-lib.0.11.6 (looking at the opam file this is one is compatible) because the latest one coq-ext-lib.0.11.7 is not (again you can look at the opam file).

Pypi package : where is my executable?

(Archlinux/Python3.5)
I'm working on a small Python3 project made up of only one Python file . With the help of tutorials like this one, I've created a Pypi package with the following commands :
$ python setup.py sdist bdist_wheel register -r pypi (ok, no error msg)
$ python setup.py sdist bdist_wheel upload -r pypi (ok, no error msg)
... and I thought I would juste have to write :
$ sudo pip install katal (ok, no error msg)
and then, e.g. :
$ katal --version
... in order to use it.
But the last command fails : there's no katal or Katal command; if I take a look at /usr/lib/Python3.5/site-packages/ , I only see the following files (no .py file have been installed !) :
/usr/lib/python3.5/site-packages/Katal-0.0.9.dist-info/DESCRIPTION.rst
/usr/lib/python3.5/site-packages/Katal-0.0.9.dist-info/METADATA
/usr/lib/python3.5/site-packages/Katal-0.0.9.dist-info/RECORD
/usr/lib/python3.5/site-packages/Katal-0.0.9.dist-info/WHEEL
/usr/lib/python3.5/site-packages/Katal-0.0.9.dist-info/metadata.json
/usr/lib/python3.5/site-packages/Katal-0.0.9.dist-info/top_level.txt
I've obviously forgotten something... But what ? My setup.py clearly defines where is the unique package of my project (=take everything but the test directory, including the katal sub-directory) :
packages=find_packages(exclude=['tests*']),
Any help would be appreciated !
in your setup.py, there is a section which is commented out:
...
##entry_points={
## 'console_scripts': [
## 'sample=sample:main',
## ],
##
...
This is where I would normally define an executable, please see this tutorial. You can also define a scripts argument to setup which works a little differently (and might match your use case a little better), but that is covered in the tutorial I linked to.

Hidden package binary-0.7.5.0?

I get this error:
Could not find module ‘Data.Binary’
It is a member of the hidden package ‘binary-0.7.5.0#binar_IvYoLp9H6Xy3zEH13MmZwd’.
as I import Data.Binary in my stack project with GHCi version 7.10.2.
Strange things are that this does not appear if I execute the GHCi through stack exec ghci, and that I cannot install newer versions of binary package through stack, which looks:
D:\p>stack install binary
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
D:\p>stack install binary-0.7.6.1
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
Error parsing targets: Specified target version 0.7.6.1 for package binary does not match snapshot version 0.7.5.0
D:\p>stack install binary-0.7.5.0
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
How would you get around this problem?
Add binary dependency to your cabal file.
build-depends: base >= 4.7 && < 5
, binary >= 0.7.5
When you use stack install you are installing certain library or executable but not as dependency (e.g. is a utility like yesod or some library you are using only inside ghci ...).

ghc-modi and cabal version

(Haskell newbie here)
I'm trying to configure HaskForce plugin into IntelliJ IDEA, configured "ghc-mod" with "legacy-interactive" in "GHC Modi" Flags. The root problem seems to be related to cabal version, although when I try autocompleting on any Haskell symbol, I get this:
ghc-modi error
Unable to parse problems from ghc-modi: cabal-helper-wrapper.exe: ghc: readCreateProcess: does not exist (No such file or directory)
ghc-mod: readCreateProcess: C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist" (exit 1): failed
When I run this last command (C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist"), it tries to install cabal 1.18:
cabal-helper-wrapper.exe: Installing Cabal version 1.18.1.3 failed.
I already have cabal, of version 1.22 (installed via Haskell Platform v7.10.2-a, released recently in August).
Is there any way to work around this issue (i.e. still use ghc-mod / ghc-modi)?
Updated Haskforce plugin (0.3-beta24) seems to work correctly with following ghc-mod:
ghc-mod version 5.4.0.0 compiled by GHC 7.10.2

Install pyqt via homebrew with `--with-python3` but still goes to Python 2

Here's my command and output (some command line arguments are left out). What is going wrong? Thank you.
$ brew reinstall pyqt --with-python3
==> Reinstalling pyqt --with-python3
==> Downloading http://downloads.sf.net/project/pyqt/PyQt4/PyQt-4.10.3/PyQt-mac-
Already downloaded: /Library/Caches/Homebrew/pyqt-4.10.3.tar.gz
==> Patching
patching file configure.py
==> python configure.py --confirm-license --bindir=/usr/local/Cellar/pyqt/4.10.3
==> python ./configure-ng.py --confirm-license --bindir=/usr/local/Cellar/pyqt/4
==> make
==> make install
==> Caveats
Set PYTHONPATH if you want Python to find your site-packages:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
==> Summary
🍺 /usr/local/Cellar/pyqt/4.10.3: 560 files, 18M, built in 6.6 minutes
UPDATE:
I think the formula of pyqt somehow hard-codes the python's version. For example it explicitly includes paths like python2.7/site-packages/. Here's part of the file:
def install
# On Mavericks we want to target libc++, this requires a non default qt makespec
if ENV.compiler == :clang and MacOS.version >= :mavericks
ENV.append "QMAKESPEC", "unsupported/macx-clang-libc++"
end
args = [ "--confirm-license",
"--bindir=#{bin}",
"--destdir=#{lib}/python2.7/site-packages",
"--sipdir=#{share}/sip" ]
# We need to run "configure.py" so that pyqtconfig.py is generated, which
# is needed by PyQWT (and many other PyQt interoperable implementations such
# as the ROS GUI libs). This file is currently needed for generating build
# files appropriate for the qmake spec that was used to build Qt. This method
# is deprecated and will be removed with SIP v5, so we do the actual compile
# using the newer configure-ng.py as recommended.
system "python", "configure.py", *args
(lib/'python2.7/site-packages').install 'pyqtconfig.py'
# On Mavericks we want to target libc++, this requires a non default qt makespec
if ENV.compiler == :clang and MacOS.version >= :mavericks
args << "--spec" << "unsupported/macx-clang-libc++"
end
system "python", "./configure-ng.py", *args
system "make"
system "make", "install"
end
You should check out this issue on Homebrew's git:
https://github.com/Homebrew/homebrew/issues/25735
We can no longer use the --with-python3 argument with pyside/pyqt/sip. Unfortunately, it seems like we can't use Homebrew for these modules in a while. They probably have to find another solution of handling the formulas for having Python 2.7 and Python3 installs first.
I scratched my head for days figuring this out. Ended up with installing PyQt from source.
Good luck.

Resources