PyCQA / pyflakes

A simple program which checks Python source files for errors
https://pypi.org/project/pyflakes
MIT License
1.36k stars 178 forks source link

`typing.no_type_check` decorator is not being considered #595

Open liiight opened 3 years ago

liiight commented 3 years ago

pyflakes does not seem to take into consideration the typing.no_type_check decorator and throws F821 undefined name error, Example (from Uplink's documentation, a great library with a custom use case for type annotation):

from uplink import Consumer, get, Path, Query
from typing import no_type_check

class GitHub(Consumer):
    """A Python Client for the GitHub API."""
    @get("users/{user}/repos")
    @no_type_check
    def get_repos(self, user: Path, sort_by: Query("sort")):
        """Get user's public repositories."""

Results of running pyflakes:

➜ pyflakes flake8_poc.py
flake8_poc.py:9:52 undefined name 'sort'

This raises no error when running using mypy for example.

sigmavirus24 commented 3 years ago

This is sort of a duplicate of #554. That Query annotation, as was already explained on Flake8's issue tracker, isn't valid PEP 484

asottile commented 3 years ago

we should still support this decorator I think, it's similar to the support for Annotation and there's already a context for disabling type annotation considering in pyflakes