The example warning I am getting is Item "None" of "Optional[IO[bytes]]" has no attribute "close"]
, as making the line bold and red. This usually occurs if Python cannot detect the type or its function.
The way I imported: from subprocess import PIPE, STDOUT, CalledProcessError, Popen, check_output
- Using
# NOQA
,# flake8: noqa
did not help, represented asflycheck-warning'
.
I still want to see the warning for unused imports but if I use # noqa
I want them to go away.
Setup file, complete section for flycheck is here: https://gist.github.com/avatar-lavventura/e8713d871696538bf59a0c0245a878ec :
(use-package flycheck-pycheckers
:after flycheck
:ensure t
:init
(with-eval-after-load 'flycheck
(add-hook 'flycheck-mode-hook #'flycheck-pycheckers-setup)
)
(setq flycheck-pycheckers-checkers
'(
mypy3
pyflakes
)
)
)
In my configuraiton I believe flake8
is enabled.
Elpy Configuration
Emacs.............: 26.3
Elpy..............: 1.34.0
Virtualenv........: venv (/home/alper/venv)
Interactive Python: python3 3.7.5 (/home/alper/venv/bin/python3)
RPC virtualenv....: rpc-venv (/home/alper/.emacs.d/elpy/rpc-venv)
Python...........: python 3.7.5 (/home/alper/.emacs.d/elpy/rpc-venv/bin/python)
Jedi.............: 0.17.2
Rope.............: 0.16.0
Autopep8.........: 1.5.4
Yapf.............: 0.30.0
Black............: 20.8b1
Syntax checker....: flake8 (/home/alper/.local/bin/flake8)
Update:
Output of flycheck-verify-setup
:
Syntax checkers for buffer Driver.py in python-mode:
First checker to run:
python-flake8
- may enable: yes
- executable: Found at /Users/alper/venv/bin/python3
- configuration file: Not found
- `flake8' module: Found at "/Users/alper/venv/lib/python3.7/site-packages/flake8/__init__.py"
- next checkers: python-mypy, python-pylint
Checkers that may run as part of the first checker's chain:
python-pylint
- may enable: yes
- executable: Found at /Users/alper/venv/bin/pylint
- configuration file: Found at "/Users/alper/.pylintrc"
- next checkers: python-mypy
python-mypy
- may enable: yes
- executable: Found at /Users/alper/venv/bin/mypy
- configuration file: Found at "/Users/alper/eBlocBroker/setup.cfg"
Checkers that could run if selected:
python-pycompile select
- may enable: yes
- executable: Found at /Users/alper/venv/bin/python3
- next checkers: python-mypy
Checkers that are compatible with this mode, but will not run until properly configured:
python-pyright (automatically disabled) reset
- may enable: no
- executable: Not found
Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.
--------------------
Flycheck version: 32snapshot (package: 20201023.1716)
Emacs version: 26.3
System: x86_64-apple-darwin19.6.0
Window system: nil
Output of M-x -> describe-variable
AND flycheck-checkers
:
flycheck-checkers is a variable defined in ‘flycheck.el’.
Its value is
(python-pycheckers solium-checker solidity-checker ada-gnat asciidoctor asciidoc awk-gawk bazel-buildifier
c/c++-clang c/c++-gcc c/c++-cppcheck cfengine chef-foodcritic coffee coffee-coffeelint coq css-csslint
css-stylelint cuda-nvcc cwl d-dmd dockerfile-hadolint elixir-credo emacs-lisp emacs-lisp-checkdoc ember-template
erlang-rebar3 erlang eruby-erubis eruby-ruumba fortran-gfortran go-gofmt go-golint go-vet go-build go-test
go-errcheck go-unconvert go-staticcheck groovy haml handlebars haskell-stack-ghc haskell-ghc haskell-hlint
html-tidy javascript-eslint javascript-jshint javascript-standard json-jsonlint json-python-json json-jq jsonnet
less less-stylelint llvm-llc lua-luacheck lua markdown-markdownlint-cli markdown-mdl nix nix-linter opam perl
perl-perlcritic php php-phpmd php-phpcs processing proselint protobuf-protoc protobuf-prototool pug puppet-parser
puppet-lint python-flake8 python-pylint python-pycompile python-pyright python-mypy r-lintr racket rpm-rpmlint
rst-sphinx rst ruby-rubocop ruby-standard ruby-reek ruby-rubylint ruby ruby-jruby rust-cargo rust rust-clippy
scala scala-scalastyle scheme-chicken scss-lint scss-stylelint sass/scss-sass-lint sass scss sh-bash
sh-posix-dash sh-posix-bash sh-zsh sh-shellcheck slim slim-lint sql-sqlint systemd-analyze tcl-nagelfar terraform
terraform-tflint tex-chktex tex-lacheck texinfo textlint typescript-tslint verilog-verilator vhdl-ghdl
xml-xmlstarlet xml-xmllint yaml-jsyaml yaml-ruby yaml-yamllint)
Original value was
(ada-gnat asciidoctor asciidoc awk-gawk bazel-buildifier c/c++-clang c/c++-gcc c/c++-cppcheck cfengine
chef-foodcritic coffee coffee-coffeelint coq css-csslint css-stylelint cuda-nvcc cwl d-dmd dockerfile-hadolint
elixir-credo emacs-lisp emacs-lisp-checkdoc ember-template erlang-rebar3 erlang eruby-erubis eruby-ruumba
fortran-gfortran go-gofmt go-golint go-vet go-build go-test go-errcheck go-unconvert go-staticcheck groovy haml
handlebars haskell-stack-ghc haskell-ghc haskell-hlint html-tidy javascript-eslint javascript-jshint
javascript-standard json-jsonlint json-python-json json-jq jsonnet less less-stylelint llvm-llc lua-luacheck lua
markdown-markdownlint-cli markdown-mdl nix nix-linter opam perl perl-perlcritic php php-phpmd php-phpcs
processing proselint protobuf-protoc protobuf-prototool pug puppet-parser puppet-lint python-flake8 python-pylint
python-pycompile python-pyright python-mypy r-lintr racket rpm-rpmlint rst-sphinx rst ruby-rubocop ruby-standard
ruby-reek ruby-rubylint ruby ruby-jruby rust-cargo rust rust-clippy scala scala-scalastyle scheme-chicken
scss-lint scss-stylelint sass/scss-sass-lint sass scss sh-bash sh-posix-dash sh-posix-bash sh-zsh sh-shellcheck
slim slim-lint sql-sqlint systemd-analyze tcl-nagelfar terraform terraform-tflint tex-chktex tex-lacheck texinfo
textlint typescript-tslint verilog-verilator vhdl-ghdl xml-xmlstarlet xml-xmllint yaml-jsyaml yaml-ruby
yaml-yamllint)
# NOQA
(or similar) syntax for ignoring errors. See (stackoverflow.com/questions/5033727/…) and (github.com/PyCQA/pyflakes/issues/431). You likely want to useflake8
instead ofpyflakes
as a syntax checker, which will allow your# NOQA
comments to work again.pyflakes
underflake8
. I think I am already usingflake8
so I just removepyflakes
from.emacs
and pip packages should resolve itpyflakes
is not defined in my.emacs
file and seems like flake8 is enables:Syntax checker....: flake8 (/home/user/.local/bin/flake8)
# NOQA
doesn't work here. Unless it has changed recently, flake8 does not look at types, so it wouldn't be able to return a warning about anAttributeError
. If the error is from mypy, adding the comment# type: ignore
may work (see: stackoverflow.com/questions/49220022). If it does not work, can you provide the values ofelpy-syntax-checker
,python-check-command
, andpython-flymake-command
in the buffer where this occurs?# type: ignore
works on my end.Forpython-check-command
I am having/home/alper/venv/lib/python3.7/site-packages is in the MYPYPATH. Please remove it.