Skip to content

[bug] Doesn't ignore explicit any on a single line #8759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
theoden-dd opened this issue May 1, 2020 · 3 comments
Closed

[bug] Doesn't ignore explicit any on a single line #8759

theoden-dd opened this issue May 1, 2020 · 3 comments

Comments

@theoden-dd
Copy link

        body: Optional[Mapping[str, Any]] = None,  # type: ignore[misc] # noqa: F821
  • What is the actual behavior/output?
    file.py:17: error: Explicit "Any" is not allowed [misc]
    file.py:22: error: unused 'type: ignore' comment

Actually, I tried no-explicit-any and no-any-explicit as error code, but neither worked.

  • What is the behavior/output you expect?
    No errors.

  • What are the versions of mypy and Python you are using?
    Python 3.8.2 mypy 0.761

  • What are the mypy flags you are using? (For example --strict-optional)
    In setup.cfg:

show_error_codes = True
disallow_any_explicit = True

Related issue: #7239

@JelleZijlstra
Copy link
Member

This sounds like there's some mismatch in line number. To fix it, you need to put the type ignore on the line that the error indicates.

But this also suggests a bug in where we raise the error. I'm just guessing, but maybe we produce an error on the def line when we should do it on the line for a specific parameter.

@theoden-dd
Copy link
Author

Thank you! That worked:

    def api_response(  # type: ignore[misc] # noqa: F821
        self,
        endpoint,
        verb: str = 'get',
        headers: Optional[Mapping[str, str]] = None,
        body: Optional[Mapping[str, Any]] = None,
    ) -> Response:

If you're sure that the solution is obvious, please, close the issue.

@emmatyping
Copy link
Member

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants