Skip to content

Commit 704fab2

Browse files
authored
Merge pull request #54 from python-discord/dev-next
Release v1.1.3
2 parents b3cdb41 + 9ef76d1 commit 704fab2

File tree

8 files changed

+35
-39
lines changed

8 files changed

+35
-39
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
Versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (`<major>`.`<minor>`.`<patch>`)
33

4+
## [v1.1.3]
5+
### Fixed
6+
* Add missing classifier test cases for POSONLYARGS
7+
* Re-add the `tree` argument to the checker so flake8 identifies the plugin as needing to run
8+
49
## [v1.1.2]
510
### Changed
611
* Request source from `flake8` as lines of code rather than parsing it from the requested filename ourselves, allowing for proper parsing of `stdin` inputs

Pipfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,3 @@ tox = "~=3.14"
2626
lint = "flake8"
2727
check_metadata = "python setup.py --quiet check --metadata --strict"
2828
precommit = "pre-commit install"
29-
test = "tox"
30-
coverage = "pytest --cov=flake8_annotations --cov=testing testing/ --cov-branch --cov-report term-missing"

README.md

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# flake8-annotations
2-
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flake8-annotations)
3-
![PyPI](https://img.shields.io/pypi/v/flake8-annotations)
2+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flake8-annotations)](https://pypi.org/project/flake8-annotations/)
3+
[![PyPI](https://img.shields.io/pypi/v/flake8-annotations)](https://pypi.org/project/flake8-annotations/)
44
[![Build Status](https://dev.azure.com/python-discord/Python%20Discord/_apis/build/status/python-discord.flake8-annotations?branchName=master)](https://dev.azure.com/python-discord/Python%20Discord/_build/latest?definitionId=16&branchName=master)
55
[![Discord](https://img.shields.io/discord/267624335836053506?color=%237289DA&label=Python%20Discord&logo=discord&logoColor=white)](https://discord.gg/2B963hn)
66

77

88
`flake8-annotations` is a plugin for [Flake8](http://flake8.pycqa.org/en/latest/) that detects the absence of [PEP 3107-style](https://www.python.org/dev/peps/pep-3107/) function annotations and [PEP 484-style](https://www.python.org/dev/peps/pep-0484/#type-comments) type comments (see: [Caveats](#Caveats-for-PEP-484-style-Type-Comments)).
99

10-
What this won't do: Check variable annotations (see: [PEP 526](https://www.python.org/dev/peps/pep-0526/)), respect stub files, or replace [mypy's](http://mypy-lang.org/) static type checking.
10+
What this won't do: Check variable annotations (see: [PEP 526](https://www.python.org/dev/peps/pep-0526/)), respect stub files, or replace [mypy](http://mypy-lang.org/).
1111

1212
## Installation
1313

@@ -23,7 +23,7 @@ You can verify it's being picked up by invoking the following in your shell:
2323

2424
```bash
2525
$ flake8 --version
26-
3.7.8 (flake8-annotations: 1.1.2, mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.7.4 on Darwin
26+
3.7.8 (flake8-annotations: 1.1.3, mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.7.4 on Darwin
2727
```
2828

2929
## Table of Warnings
@@ -123,32 +123,17 @@ A [pre-commit](https://pre-commit.com) installation script and configuration is
123123
$ pipenv run precommit
124124
```
125125

126-
### Testing
127-
A [pytest](https://docs.pytest.org/en/latest/) suite is provided for testing across multiple Python environments via [tox](https://github.com/tox-dev/tox/):
126+
or
128127

129128
```bash
130-
$ pipenv run test
129+
$ pre-commit install
131130
```
132131

133-
### Coverage
134-
Test coverage is provided by [pytest-cov](https://github.com/pytest-dev/pytest-cov) via a pipenv script:
132+
### Testing & Coverage
133+
A [pytest](https://docs.pytest.org/en/latest/) suite is provided, with coverage reporting from [pytest-cov](https://github.com/pytest-dev/pytest-cov). A [tox](https://github.com/tox-dev/tox/) configuration is provided to test across all supported versions of Python. Testing will be skipped for Python versions that cannot be found.
135134

136135
```bash
137-
$ pipenv run coverage
136+
$ tox
138137
```
139138

140-
When running via pipenv, details on missing coverage is provided in the report to allow the user to generate additional tests for full coverage.
141-
142-
e.g.
143-
144-
```
145-
----------- coverage: platform win32, python 3.7.4-final-0 -----------
146-
Name Stmts Miss Branch BrPart Cover Missing
147-
-------------------------------------------------------------------------------
148-
flake8_annotations\__init__.py 108 0 38 0 99% 164
149-
flake8_annotations\checker.py 57 0 30 0 100%
150-
flake8_annotations\enums.py 15 0 0 0 100%
151-
flake8_annotations\error_codes.py 85 0 0 0 100%
152-
-------------------------------------------------------------------------------
153-
TOTAL 265 0 68 0 99%
154-
```
139+
Details on missing coverage, including in the test suite, is provided in the report to allow the user to generate additional tests for full coverage.

flake8_annotations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
PY_GTE_38 = False
1919

20-
__version__ = "1.1.2"
20+
__version__ = "1.1.3"
2121

2222
AST_ARG_TYPES = ("args", "vararg", "kwonlyargs", "kwarg")
2323
if PY_GTE_38:

flake8_annotations/checker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class TypeHintChecker:
2525
name = "flake8-annotations"
2626
version = __version__
2727

28-
def __init__(self, lines: List[str]):
28+
def __init__(self, tree: ast.Module, lines: List[str]):
29+
# Request `tree` in order to ensure flake8 will run the plugin, even though we don't use it
2930
# Request `lines` here and join to allow for correct handling of input from stdin
3031
self.lines = lines
3132
self.tree = self.get_typed_tree("".join(lines)) # flake8 doesn't strip newlines

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
setup(
55
name="flake8-annotations",
66
license="MIT",
7-
version="1.1.2",
7+
version="1.1.3",
88
description="Flake8 Type Annotation Checks",
99
long_description=open("README.md", encoding="utf-8").read(),
1010
long_description_content_type="text/markdown",

testing/helpers.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def parse_source(src: str) -> Tuple[ast.Module, List[str]]:
2727
def check_source(src: str) -> Generator[Error, None, None]:
2828
"""Helper for generating linting errors from the provided source code."""
2929
_, lines = parse_source(src)
30-
checker_instance = TypeHintChecker(lines)
30+
checker_instance = TypeHintChecker(None, lines)
3131

3232
return checker_instance.run()
3333

@@ -43,10 +43,9 @@ def functions_from_source(src: str) -> List[Function]:
4343

4444
def find_matching_function(func_list: Iterable[Function], match_name: str) -> Optional[Function]:
4545
"""
46-
Iterate over a list of Function objects & find the matching named function.
46+
Iterate over a list of Function objects & find the first matching named function.
4747
48-
If no function is found, this returns None
48+
Due to the definition of the test cases, this should always return something, but there is no
49+
protection if a match isn't found & will raise an `IndexError`.
4950
"""
50-
for function in func_list:
51-
if function.name == match_name:
52-
return function
51+
return [function for function in func_list if function.name == match_name][0]

testing/test_cases/classifier_object_attributes.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,21 @@ class AT(NamedTuple):
8181
AT(True, False, ClassDecoratorType.CLASSMETHOD, AnnotationType.ARGS): error_codes.TYP001,
8282
AT(True, True, ClassDecoratorType.STATICMETHOD, AnnotationType.ARGS): error_codes.TYP001,
8383
AT(True, False, ClassDecoratorType.STATICMETHOD, AnnotationType.ARGS): error_codes.TYP001,
84-
AT(True, False, None, AnnotationType.ARGS): error_codes.TYP001,
85-
AT(False, True, None, AnnotationType.ARGS): error_codes.TYP001,
86-
AT(False, False, None, AnnotationType.ARGS): error_codes.TYP001,
8784
AT(True, False, ClassDecoratorType.CLASSMETHOD, AnnotationType.KWONLYARGS): error_codes.TYP001,
8885
AT(True, True, ClassDecoratorType.STATICMETHOD, AnnotationType.KWONLYARGS): error_codes.TYP001,
8986
AT(True, False, ClassDecoratorType.STATICMETHOD, AnnotationType.KWONLYARGS): error_codes.TYP001,
87+
AT(True, False, ClassDecoratorType.CLASSMETHOD, AnnotationType.POSONLYARGS): error_codes.TYP001,
88+
AT(True, True, ClassDecoratorType.STATICMETHOD, AnnotationType.POSONLYARGS): error_codes.TYP001,
89+
AT(
90+
True, False, ClassDecoratorType.STATICMETHOD, AnnotationType.POSONLYARGS
91+
): error_codes.TYP001,
92+
AT(True, False, None, AnnotationType.ARGS): error_codes.TYP001,
93+
AT(False, True, None, AnnotationType.ARGS): error_codes.TYP001,
94+
AT(False, False, None, AnnotationType.ARGS): error_codes.TYP001,
9095
AT(True, False, None, AnnotationType.KWONLYARGS): error_codes.TYP001,
9196
AT(False, True, None, AnnotationType.KWONLYARGS): error_codes.TYP001,
9297
AT(False, False, None, AnnotationType.KWONLYARGS): error_codes.TYP001,
98+
AT(True, False, None, AnnotationType.POSONLYARGS): error_codes.TYP001,
99+
AT(False, True, None, AnnotationType.POSONLYARGS): error_codes.TYP001,
100+
AT(False, False, None, AnnotationType.POSONLYARGS): error_codes.TYP001,
93101
}

0 commit comments

Comments
 (0)