question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pre-hook finds error: unused 'type: ignore' comment while local mypy doesn't

See original GitHub issue

hello, pre-commit finds some error: unused 'type: ignore' comment while local mypy doesn’t.

git:(master) ✗ mypy src/settings.py
Success: no issues found in 1 source file
git:(master) ✗ pre-commit run mypy --verbose --files src/settings.py
mypy.....................................................................Failed
- hook id: mypy
- duration: 0.32s
- exit code: 1

src/settings.py:15: error: unused 'type: ignore' comment
src/settings.py:31: error: unused 'type: ignore' comment
Found 2 errors in 1 file (checked 1 source file)

my pre-commit config is below, it uses same version as mypy local. the discrepancy disappears if I uncomment the # args: [--no-warn-unused-ignores] line but that’s not what I got in my mypy.ini so that would seem a rather harsh fix:

git:(master) ✗ cat .pre-commit-config.yaml
repos:
  - repo: https://github.com/psf/black
    rev: 19.10b0
    hooks:
      - id: black
  - repo: https://gitlab.com/pycqa/flake8
    rev: 3.7.9
    hooks:
      - id: flake8
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.761
    hooks:
      - id: mypy
#        args: [--no-warn-unused-ignores]                          

local mypy version with it’s configL

 git:(master) ✗ pre-commit --version
pre-commit 1.21.0
git:(master) ✗ mypy --version
mypy 0.761
git:(master) ✗ cat mypy.ini 
[mypy]
python_version=3.8
platform=linux

follow_imports = silent
disallow_any_generics = True
ignore_missing_imports = True

# be strict
disallow_untyped_calls=True
warn_return_any=True
strict_optional=True
warn_no_return=True
warn_redundant_casts=True
warn_unused_ignores=True

# for strict mypy: (this is the tricky one :-))
disallow_untyped_defs = True
check_untyped_defs = True

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
euri10commented, Jan 8, 2020

I re-emphasized a point that’s already in the README, maybe this applies to your situation? eef73e2

I indeed fixed it adding additional_dependencies: [pydantic==1.3.0, httpx==0.10.0] Sorry I overlooked that part of the Readme and thanks for your help !

1reaction
asottilecommented, Jan 8, 2020

I re-emphasized a point that’s already in the README, maybe this applies to your situation? https://github.com/pre-commit/mirrors-mypy/commit/eef73e213c40a4d91c350235112c6bee263be7af

Read more comments on GitHub >

github_iconTop Results From Across the Web

mypy: pre-commit results differ from - Stack Overflow
dumps , so it seems that this should pass (it returns bytes to be precise, but not Any ). The other type of...
Read more >
Supported hooks - pre-commit
Sample annotations: `# type: ignore[attr-defined]`, `# type: ... type comments; rst-backticks - Detect common mistake of using single backticks when writing ...
Read more >
Common issues and solutions - mypy 0.991 documentation
Spurious errors and locally silencing the checker#. You can use a # type: ignore comment to silence the type checker on a particular...
Read more >
"# type: ignore" to ignore more than one line - Python mailing list
I've seen no user requests for mypy to enable the full PEP 484 behavior, but people do ask for a way to disable...
Read more >
Support "type: ignore" comments from PEP 484 : PY-19917
Unfortunately when you use this in PyCharm you get an "Unresolved reference 'ignore'" code quality error. Could pycharm support this directive too?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found