| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
| |
subscript (#609)
|
| |
|
| |
|
|
|
|
| |
TypeVar has such contexts in the positional arguments (for constraints)
and in the `bound` keyword argument.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Test on GitHub Actions
* Add 2.7 and 3.5 to GHA
* Remove Travis CI and AppVeyor
* Simplify config
Co-authored-by: Anthony Sottile <asottile@umich.edu>
* Review updates
* Remove redundant line
Co-authored-by: Anthony Sottile <asottile@umich.edu>
|
|
|
| |
Relates #259.
|
| |
|
|
|
| |
Stop allowing failures on Python nightly.
|
|
|
|
|
|
|
| |
* Fix test_invalidEscape with recent PyPy3 versions, closes #584
* CI: update PyPY version in Travis and AppVeyor
Also make it easier to update for AppVeyor.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* fix: don't return syntax error for Annotated's metadata
PEP 593 https://www.python.org/dev/peps/pep-0593/ introduced the type Annotated, which allows to add metadata to types. By the definition only the first argument is required to be a proper type, all the other arguments are dependent on the consumer and can be other types or even literals.
This PR fixes #574.
* fix whitespace
* fix tests and formatting
* PR comments from asottile
* fix _in_annotation and remove _in_typing_annotated field
* fix test name
* get rid of _exit_annotation in favor of _entger_annotation(AnnotationState.None)
* handle Annotated in python3.9+
Co-authored-by: Anthony Sottile <asottile@umich.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix undefined name in annotations
Variable annotations without a value don't create a name, but they still
can be used as variable annotation themselves as long as the annotation
is quoted or "from __future__ import annotations" is used.
The implementation introduces a new binding "Annotation" for these kinds
of variable annotations. This can potentially be used for further
annotation-related checks in the future.
Annotation handling is extended to be able to detect both forms of postponed
annotations (quoted and future import) during checks.
Fixes #486
* Fix wrong tuple syntax
* Refactor annotation handling
* Introduce AnnotationState "enum"
* Pass AnnotationState to _enter_annotation() instead of a "string" flag
* Add a test for unused annotations
* Add a few more tests for unused variables
|
|
|
|
|
|
|
| |
* Extend F822 to support tuple concatenation
* Add test case
* Use camel case
|
| |
|
|
|
|
|
|
|
|
|
| |
* Add Python 3.8 to Travis
* Add Python 3.8 to Tox
* Add Python 3.8 trove classifier
* List Python 3.8 as supported in the README
|
|
|
|
|
| |
* Add tests demonstrating common use of TYPE_CHECKING guards
* Add another example using a runtime guard for Protocol
|
|
|
|
|
|
|
| |
* Fix test for nightly Python (3.9)
* allow_failures: true for nightly
Co-authored-by: Anthony Sottile <asottile@umich.edu>
|
| |
|
|
|
|
|
| |
* Fix pyflakes for removal of ast.Param
* Remove AugStore / AugLoad (not even used in py2)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Extract a context manager for when we're in a annotation context
* Detect quoted type annotations within typing.cast calls
* Refactor typing name check
This will make it easier to detect an unspecified typing module
member as well as opening up other checks (such as testing for
one of a collection many members all in one go).
* Detect quoted annotations within subscripts of typing classes
* Add nested quoted test case (Callable)
* Use a lambda here for clarity
This is slightly more usual than accessing a .__eq__ method and is
more obviously similar to the other usage of this helper.
|
|
|
|
|
| |
* Deprecate optparse in favor of argparse
* Support '-V' as an alias for '--version'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add a check for if statement conditions which are non-empty tuples
With the increasing prevalence of wrapping conditionals like:
if (
some_value != 'some_condition' and
other_value is not 42
)
and for wrapping other constructs with trailing commas, like:
x = (
some_value,
other_value,
)
it becomes quite easy to accidentally combine these into a
conditional statement which is actually always true:
if (
some_value != 'some_condition' and
other_value is not 42,
)
This commit introduces a check for such constructs.
* Make this error message make sense
* Further clarity this message's docstring
Co-Authored-By: Ran Benita <ran234@gmail.com>
Co-authored-by: Ran Benita <ran234@gmail.com>
|
|
|
| |
As commented in https://github.com/PyCQA/pyflakes/pull/512#discussion_r392587730
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix bug in async function scope checking
Previously attempting to check an async function scoped tree would
immediately error because tuples are not callable.
The test added here is a direct copy of 'test_scope_function' as
I'm not sure what (if anything) should specifically be tested for
async functions, though it serves to prove the fix.
* Skip async function test where it doesn't apply
* Clarify that this is a smoke test for async function segments
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
| |
They are synonyms and typing_extensions.overloads works on 3.5.1.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* In PEP 484 type comments, allow text after "# type: ignore"
This is to support allowing typecheckers to implement ignores for
specific errors, using syntax like `# type: ignore=E1000` or
`# type: ignore[type-mismatch` or some such.
mypy is about to add support for ignoring specific errors following
this design: https://github.com/python/mypy/issues/7239
Support for extra text in type comments was implemented
in CPython as https://bugs.python.org/issue36878
and in typed_ast as https://github.com/python/typed_ast/pull/116.
* add test back
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Recognize python with arguments in shebang
* Recognize python with d/m/u suffix in shebang
https://www.python.org/dev/peps/pep-3149/#proposal
* Recognize python with minor version in shebang
* Avoid unnecessary line splitting in shebang search
* Add test for python shebang-like not on the first line
|
|
|
|
|
|
|
|
| |
* Add lint rule for f-strings without placeholders
* Add linting for string.format(...)
* Add linting for % formatting
|
|
|
| |
This closes #409.
|
| |
|
|\
| |
| |
| | |
Forgot to push this to master. Whoops.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Do not define a special `_` name in doctest scope when the global scope
already has a `_`. This mirrors the way doctests actually work: the
special `_` value is assigned only when a global of that name doesn't
already exist.
Fixes #421.
|
| |
| |
| |
| |
| |
| | |
* fix annotation is class level variable caused undefined
* update skipif condition
|
| |
| |
| |
| |
| |
| | |
* Add another test for #422
* remove old test
|
| |
| |
| |
| |
| |
| | |
* Support @overload mixed with other decorators
* Detect @overload not just at module scope
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Include column numbers with all error messages
As long as the node passed to the message has a col_offset, it is included in
the message. There is already a precedent of printing the column number for
syntax errors.
This changes the API slightly, in that if col_offset is not present on the
node, the message.col is now -1 instead of 0. Otherwise, there would be no way
to distinguish between errors that have no column number and errors with a
column number 0. If this doesn't seem like an acceptable change, I can revert
it, and either always use 0 as the default, or use a separate attribute to
indicate if the message.col is the "real" column number.
I haven't yet tested everything, but I'm not even sure if there are any nodes
that don't have a col_offset. There don't appear to be any represented in the
test suite.
* Simplify some code
* Make column numbers start at 1
This also reverts an API break. message.col now defaults to 0 again, instead
of -1 (0 means there is no column number and so it isn't included in the
printed error message).
* Revert column number API change
It broke a lot of tests.
Now, to minimize API changes as much as possible:
- The message.col attribute starts at 0, same as the AST col_offset
- message.col is also 0 even if col_offset doesn't exist. Note that currently
there aren't any nodes represented in the pyflakes test suite that don't
have col_offset. Such nodes do exist in the ast module, but it seems
unlikely that they would ever result in a message (only expr and stmt nodes
have it, so for instance a Module node would not).
- The str version of the message starts columns at 1, which is consistent with
the existing messages for syntax errors, as well as other tools such as
flake8.
* Fix flake8 issue
Fixes #158
Fixes #425
|