From 9877ff5b0182993743bc97f7f9b581b9eaa2805e Mon Sep 17 00:00:00 2001 From: Bastien Gerard Date: Thu, 20 May 2021 10:54:15 +0200 Subject: [PATCH 1/6] fix performance issue due to search in tokens --- flake8_eradicate.py | 49 +++++++++++++++++++----------------------- tests/test_comments.py | 35 ++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/flake8_eradicate.py b/flake8_eradicate.py index f8ee8bf..8a407b5 100644 --- a/flake8_eradicate.py +++ b/flake8_eradicate.py @@ -25,14 +25,9 @@ class Checker(object): options = None - def __init__(self, physical_line, tokens) -> None: - """ - Creates new checker instance. + def __init__(self, tree, filename: str): + self.filename = filename - When performance will be an issue - we can refactor it. - """ - self._physical_line = physical_line - self._tokens = tokens self._options = { 'aggressive': self.options.eradicate_aggressive, # type: ignore } @@ -103,14 +98,14 @@ def parse_options(cls, options) -> None: """Parses registered options for providing them to each visitor.""" cls.options = options - def __iter__(self) -> Iterable[Tuple[int, str]]: + def run(self) -> Iterable[Tuple[int, str]]: """Runs on each step of flake8.""" - if self._contains_commented_out_code(): - yield (1, self._error_template) + for line_no in self._lines_with_commented_out_code(): + yield line_no, 0, self._error_template, type(self) - def _contains_commented_out_code(self) -> bool: + def _lines_with_commented_out_code(self) -> Iterable[int]: """ - Check if the current physical line contains commented out code. + Yield the physical line number that contain commented out code. This test relies on eradicate function to remove commented out code from a physical line. @@ -121,19 +116,19 @@ def _contains_commented_out_code(self) -> bool: To prevent this false-positive, the tokens of the physical line are checked for a comment. The eradicate function is only invokes, when the tokens indicate a comment in the physical line. - """ - comment_in_line = any( - token_type == tokenize.COMMENT - for token_type, _, _, _, _ in self._tokens - ) - - if comment_in_line: - filtered_source = ''.join( - self._eradicator.filter_commented_out_code( - self._physical_line, - self._options['aggressive'], - ), - ) - return self._physical_line != filtered_source - return False + with open(self.filename) as f: + file_tokens = tokenize.generate_tokens(f.readline) + comment_in_file = any(token.type == tokenize.COMMENT for token in file_tokens) + + if comment_in_file: + f.seek(0) # rewind file + for line_no, line in enumerate(f.readlines(), start=1): + filtered_source = ''.join( + self._eradicator.filter_commented_out_code( + line, + self._options['aggressive'], + ), + ) + if line != filtered_source: + yield line_no diff --git a/tests/test_comments.py b/tests/test_comments.py index 2b84120..fb5968e 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -2,8 +2,11 @@ import subprocess import sys +from collections import namedtuple -PY36 = sys.version_info >= (3, 6) +from flake8_eradicate import Checker + +PY_GTE_36 = sys.version_info >= (3, 6) def test_correct_fixture(absolute_path): @@ -43,9 +46,9 @@ def test_incorrect_fixture(absolute_path): ) stdout, _ = process.communicate() - assert stdout.count(b'E800') == 6 + int(PY36) + assert stdout.count(b'E800') == 6 + int(PY_GTE_36) assert b'# property_name = 1' in stdout - if PY36: + if PY_GTE_36: assert b'# typed_property: int = 10' in stdout @@ -66,9 +69,9 @@ def test_incorrect_fixture_aggressive(absolute_path): stderr=subprocess.PIPE, ) stdout, _ = process.communicate() - assert stdout.count(b'E800') == 12 + int(PY36) + assert stdout.count(b'E800') == 12 + int(PY_GTE_36) assert b'# property_name = 1' in stdout - if PY36: + if PY_GTE_36: assert b'# typed_property: int = 10' in stdout assert b'# def function_name():' in stdout assert b'# class CommentedClass(object):' in stdout @@ -93,9 +96,9 @@ def test_incorrect_fixture_whitelist(absolute_path): ) stdout, _ = process.communicate() - assert stdout.count(b'E800') == 6 + int(PY36) * 3 + assert stdout.count(b'E800') == 6 + int(PY_GTE_36) * 3 assert b'# property_name = 1' in stdout - if PY36: + if PY_GTE_36: assert b'# typed_property: int = 10' in stdout assert b'# fmt: on' in stdout assert b'# fmt: off' in stdout @@ -120,8 +123,22 @@ def test_incorrect_fixture_whitelist_extend(absolute_path): ) stdout, _ = process.communicate() - assert stdout.count(b'E800') == 3 + int(PY36) + assert stdout.count(b'E800') == 3 + int(PY_GTE_36) assert b'# property_name = 1' in stdout assert b'return' not in stdout - if PY36: + if PY_GTE_36: assert b'# typed_property: int = 10' in stdout + + +def test__lines_with_commented_out_code_incorrect_fixture_output(absolute_path): + filename = absolute_path('fixtures', 'incorrect.py') + + OptionsStub = namedtuple('Options', 'eradicate_aggressive eradicate_whitelist eradicate_whitelist_extend') + Checker.options = OptionsStub(eradicate_aggressive=True, eradicate_whitelist=False, eradicate_whitelist_extend=False) + + checker = Checker(tree=None, filename=filename) + output = list(checker._lines_with_commented_out_code()) + if PY_GTE_36: + assert output == [3, 4, 9, 10, 14, 15, 16, 18, 19, 21, 22, 24, 25] + else: + assert output == [3, 9, 10, 14, 15, 16, 18, 19, 21, 22, 24, 25] From 68937437d5103780c5d977d3cebb115feaa2faba Mon Sep 17 00:00:00 2001 From: Bastien Gerard Date: Thu, 20 May 2021 11:40:00 +0200 Subject: [PATCH 2/6] fix flake8 warnings and review comment --- flake8_eradicate.py | 7 +++++-- tests/test_comments.py | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/flake8_eradicate.py b/flake8_eradicate.py index 8a407b5..611140c 100644 --- a/flake8_eradicate.py +++ b/flake8_eradicate.py @@ -25,7 +25,7 @@ class Checker(object): options = None - def __init__(self, tree, filename: str): + def __init__(self, tree, filename: str): # noqa: D107 self.filename = filename self._options = { @@ -119,7 +119,10 @@ def _lines_with_commented_out_code(self) -> Iterable[int]: """ with open(self.filename) as f: file_tokens = tokenize.generate_tokens(f.readline) - comment_in_file = any(token.type == tokenize.COMMENT for token in file_tokens) + comment_in_file = any( + token.type == tokenize.COMMENT + for token in file_tokens + ) if comment_in_file: f.seek(0) # rewind file diff --git a/tests/test_comments.py b/tests/test_comments.py index fb5968e..4ed8db7 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -130,11 +130,19 @@ def test_incorrect_fixture_whitelist_extend(absolute_path): assert b'# typed_property: int = 10' in stdout -def test__lines_with_commented_out_code_incorrect_fixture_output(absolute_path): +def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): + """Verify central underlying method is returning correct output.""" filename = absolute_path('fixtures', 'incorrect.py') - OptionsStub = namedtuple('Options', 'eradicate_aggressive eradicate_whitelist eradicate_whitelist_extend') - Checker.options = OptionsStub(eradicate_aggressive=True, eradicate_whitelist=False, eradicate_whitelist_extend=False) + OptionsStub = namedtuple( + 'Options', + 'eradicate_aggressive eradicate_whitelist eradicate_whitelist_extend' + ) + Checker.options = OptionsStub( + eradicate_aggressive=True, + eradicate_whitelist=False, + eradicate_whitelist_extend=False + ) checker = Checker(tree=None, filename=filename) output = list(checker._lines_with_commented_out_code()) From 5a46fde3e5745568277d84eed1f34eaf0228a1b0 Mon Sep 17 00:00:00 2001 From: Bastien Gerard Date: Fri, 21 May 2021 10:46:23 +0200 Subject: [PATCH 3/6] fix from review. --- flake8_eradicate.py | 23 +++++++++++++++++++---- tests/fixtures/correct_no_comment.py | 16 ++++++++++++++++ tests/test_comments.py | 26 ++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 tests/fixtures/correct_no_comment.py diff --git a/flake8_eradicate.py b/flake8_eradicate.py index 611140c..0528a08 100644 --- a/flake8_eradicate.py +++ b/flake8_eradicate.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- +import ast import tokenize -from typing import Iterable, Tuple +from typing import Iterable, Iterator, Tuple, Type import pkg_resources from eradicate import Eradicator @@ -25,7 +26,15 @@ class Checker(object): options = None - def __init__(self, tree, filename: str): # noqa: D107 + def __init__(self, tree: ast.AST, filename: str): + """ + ``flake8`` plugin constructor. + + Arguments: + tree: the file abstract syntax tree. + filename: the name of the file to process + + """ self.filename = filename self._options = { @@ -98,7 +107,7 @@ def parse_options(cls, options) -> None: """Parses registered options for providing them to each visitor.""" cls.options = options - def run(self) -> Iterable[Tuple[int, str]]: + def run(self) -> Iterator[Tuple[int, int, str, Type['Checker']]]: """Runs on each step of flake8.""" for line_no in self._lines_with_commented_out_code(): yield line_no, 0, self._error_template, type(self) @@ -118,6 +127,12 @@ def _lines_with_commented_out_code(self) -> Iterable[int]: when the tokens indicate a comment in the physical line. """ with open(self.filename) as f: + # Skip python commented encoding line + first_line = f.readline() + if not first_line.startswith('# -*- coding:'): + # rewind as we don't want to skip it during tokenization + f.seek(0) + file_tokens = tokenize.generate_tokens(f.readline) comment_in_file = any( token.type == tokenize.COMMENT @@ -125,7 +140,7 @@ def _lines_with_commented_out_code(self) -> Iterable[int]: ) if comment_in_file: - f.seek(0) # rewind file + f.seek(0) for line_no, line in enumerate(f.readlines(), start=1): filtered_source = ''.join( self._eradicator.filter_commented_out_code( diff --git a/tests/fixtures/correct_no_comment.py b/tests/fixtures/correct_no_comment.py new file mode 100644 index 0000000..f602be7 --- /dev/null +++ b/tests/fixtures/correct_no_comment.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +class Some(object): + + property_name = 1 + + other_property: int = 2 + + def some_method(self) -> None: + print('not True and not False') + + print(12 + 23 / 3) + + +def some_function(): + return "something" diff --git a/tests/test_comments.py b/tests/test_comments.py index 4ed8db7..927550b 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -136,12 +136,12 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): OptionsStub = namedtuple( 'Options', - 'eradicate_aggressive eradicate_whitelist eradicate_whitelist_extend' + 'eradicate_aggressive eradicate_whitelist eradicate_whitelist_extend', ) Checker.options = OptionsStub( eradicate_aggressive=True, eradicate_whitelist=False, - eradicate_whitelist_extend=False + eradicate_whitelist_extend=False, ) checker = Checker(tree=None, filename=filename) @@ -150,3 +150,25 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): assert output == [3, 4, 9, 10, 14, 15, 16, 18, 19, 21, 22, 24, 25] else: assert output == [3, 9, 10, 14, 15, 16, 18, 19, 21, 22, 24, 25] + + +def test_lines_with_commented_out_code_file_without_comment_output( + absolute_path, +): + """Verify central underlying method is returning correct output + and skips python file encoding first line""" + filename = absolute_path('fixtures', 'correct_no_comment.py') + + OptionsStub = namedtuple( + 'Options', + 'eradicate_aggressive eradicate_whitelist eradicate_whitelist_extend', + ) + Checker.options = OptionsStub( + eradicate_aggressive=True, + eradicate_whitelist=False, + eradicate_whitelist_extend=False, + ) + + checker = Checker(tree=None, filename=filename) + output = list(checker._lines_with_commented_out_code()) + assert output == [] From 4483ce270d41532c5f15c9d53ef846eb2f7a8446 Mon Sep 17 00:00:00 2001 From: Bastien Gerard Date: Fri, 21 May 2021 20:17:33 +0200 Subject: [PATCH 4/6] more flake8 fix --- tests/test_comments.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_comments.py b/tests/test_comments.py index 927550b..0374f98 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -155,8 +155,7 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): def test_lines_with_commented_out_code_file_without_comment_output( absolute_path, ): - """Verify central underlying method is returning correct output - and skips python file encoding first line""" + """Make sure file without comment are ignored.""" filename = absolute_path('fixtures', 'correct_no_comment.py') OptionsStub = namedtuple( From 6a3ccfcd55d1b27551cb7704f9007ac22bf6d68d Mon Sep 17 00:00:00 2001 From: Bastien Gerard Date: Tue, 25 May 2021 21:49:49 +0200 Subject: [PATCH 5/6] Use flake8 builtin file_tokens --- flake8_eradicate.py | 20 +++++++++----------- tests/fixtures/correct_no_comment.py | 2 -- tests/test_comments.py | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/flake8_eradicate.py b/flake8_eradicate.py index 0528a08..c8dd874 100644 --- a/flake8_eradicate.py +++ b/flake8_eradicate.py @@ -2,7 +2,7 @@ import ast import tokenize -from typing import Iterable, Iterator, Tuple, Type +from typing import Iterable, Iterator, List, Tuple, Type import pkg_resources from eradicate import Eradicator @@ -26,16 +26,21 @@ class Checker(object): options = None - def __init__(self, tree: ast.AST, filename: str): + def __init__( + self, tree: ast.AST, + filename: str, + file_tokens: List[tokenize.TokenInfo], + ): """ ``flake8`` plugin constructor. Arguments: tree: the file abstract syntax tree. filename: the name of the file to process - + file_tokens: file tokens """ self.filename = filename + self.file_tokens = file_tokens self._options = { 'aggressive': self.options.eradicate_aggressive, # type: ignore @@ -127,16 +132,9 @@ def _lines_with_commented_out_code(self) -> Iterable[int]: when the tokens indicate a comment in the physical line. """ with open(self.filename) as f: - # Skip python commented encoding line - first_line = f.readline() - if not first_line.startswith('# -*- coding:'): - # rewind as we don't want to skip it during tokenization - f.seek(0) - - file_tokens = tokenize.generate_tokens(f.readline) comment_in_file = any( token.type == tokenize.COMMENT - for token in file_tokens + for token in self.file_tokens ) if comment_in_file: diff --git a/tests/fixtures/correct_no_comment.py b/tests/fixtures/correct_no_comment.py index f602be7..e327711 100644 --- a/tests/fixtures/correct_no_comment.py +++ b/tests/fixtures/correct_no_comment.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - class Some(object): property_name = 1 diff --git a/tests/test_comments.py b/tests/test_comments.py index 0374f98..188b7ee 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -2,6 +2,7 @@ import subprocess import sys +import tokenize from collections import namedtuple from flake8_eradicate import Checker @@ -9,6 +10,11 @@ PY_GTE_36 = sys.version_info >= (3, 6) +def _get_file_tokens(filename: str): + with open(filename) as f: + return list(tokenize.generate_tokens(f.readline)) + + def test_correct_fixture(absolute_path): """End-to-End test to check that correct code works.""" filename = absolute_path('fixtures', 'correct.py') @@ -144,7 +150,11 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): eradicate_whitelist_extend=False, ) - checker = Checker(tree=None, filename=filename) + checker = Checker( + tree=None, + filename=filename, + file_tokens=_get_file_tokens(filename), + ) output = list(checker._lines_with_commented_out_code()) if PY_GTE_36: assert output == [3, 4, 9, 10, 14, 15, 16, 18, 19, 21, 22, 24, 25] @@ -152,7 +162,7 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): assert output == [3, 9, 10, 14, 15, 16, 18, 19, 21, 22, 24, 25] -def test_lines_with_commented_out_code_file_without_comment_output( +def test_lines_with_commented_out_code_file_no_comment( absolute_path, ): """Make sure file without comment are ignored.""" @@ -168,6 +178,10 @@ def test_lines_with_commented_out_code_file_without_comment_output( eradicate_whitelist_extend=False, ) - checker = Checker(tree=None, filename=filename) + checker = Checker( + tree=None, + filename=filename, + file_tokens=_get_file_tokens(filename), + ) output = list(checker._lines_with_commented_out_code()) assert output == [] From 5f6b8750135f4c7decd30dc505e5e23eb1e1dc46 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 22 Jun 2021 13:10:26 +0300 Subject: [PATCH 6/6] Refactoring --- .github/workflows/test.yml | 9 +- CHANGELOG.md | 7 ++ flake8_eradicate.py | 61 +++++----- poetry.lock | 227 +++++++++++++++++++------------------ pyproject.toml | 5 +- tests/conftest.py | 22 +++- tests/test_comments.py | 24 ++-- tests/test_version.py | 2 - 8 files changed, 193 insertions(+), 164 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9028c7e..48c70b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,11 @@ name: test -on: [push, pull_request, workflow_dispatch] +on: + push: + branches: + - master + pull_request: + workflow_dispatch: jobs: build: @@ -25,7 +30,7 @@ jobs: echo "$HOME/.poetry/bin" >> $GITHUB_PATH - name: Set up cache - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: .venv key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 88cd3ca..7036c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ We follow Semantic Versions since the `0.1.0` release. +## 1.1.0 + +### Features + +- Imrpoves performance on long files #210 + + ## 1.0.0 ### Features diff --git a/flake8_eradicate.py b/flake8_eradicate.py index c8dd874..976401c 100644 --- a/flake8_eradicate.py +++ b/flake8_eradicate.py @@ -1,8 +1,5 @@ -# -*- coding: utf-8 -*- - -import ast import tokenize -from typing import Iterable, Iterator, List, Tuple, Type +from typing import Iterable, Iterator, List, Sequence, Tuple, Type import pkg_resources from eradicate import Eradicator @@ -14,6 +11,7 @@ #: We store the version number inside the `pyproject.toml`: pkg_version = pkg_resources.get_distribution(pkg_name).version +#: Const for `stdin` mode of `flake8`: STDIN = 'stdin' @@ -22,26 +20,27 @@ class Checker(object): name = pkg_name version = pkg_version + _error_template = 'E800 Found commented out code' options = None def __init__( - self, tree: ast.AST, - filename: str, + self, + tree, # that's the hack we use to trigger this check file_tokens: List[tokenize.TokenInfo], - ): + lines: Sequence[str], + ) -> None: """ ``flake8`` plugin constructor. Arguments: - tree: the file abstract syntax tree. - filename: the name of the file to process - file_tokens: file tokens - """ - self.filename = filename - self.file_tokens = file_tokens + file_tokens: all tokens for this file. + lines: all file lines. + """ + self._file_tokens = file_tokens + self._lines = lines self._options = { 'aggressive': self.options.eradicate_aggressive, # type: ignore } @@ -53,11 +52,13 @@ def __init__( if whitelist_ext: self._eradicator.update_whitelist( - whitelist_ext.split('#'), True, + whitelist_ext.split('#'), + extend_default=True, ) elif whitelist: self._eradicator.update_whitelist( - whitelist.split('#'), False, + whitelist.split('#'), + extend_default=False, ) @classmethod @@ -131,20 +132,18 @@ def _lines_with_commented_out_code(self) -> Iterable[int]: checked for a comment. The eradicate function is only invokes, when the tokens indicate a comment in the physical line. """ - with open(self.filename) as f: - comment_in_file = any( - token.type == tokenize.COMMENT - for token in self.file_tokens - ) + comment_in_file = any( + token.type == tokenize.COMMENT + for token in self._file_tokens + ) - if comment_in_file: - f.seek(0) - for line_no, line in enumerate(f.readlines(), start=1): - filtered_source = ''.join( - self._eradicator.filter_commented_out_code( - line, - self._options['aggressive'], - ), - ) - if line != filtered_source: - yield line_no + if comment_in_file: + for line_no, line in enumerate(self._lines): + filtered_source = ''.join( + self._eradicator.filter_commented_out_code( + line, + aggressive=self._options['aggressive'], + ), + ) + if line != filtered_source: + yield line_no + 1 diff --git a/poetry.lock b/poetry.lock index 00ad017..35699d6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -22,7 +22,7 @@ tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (> [[package]] name = "certifi" -version = "2020.12.5" +version = "2021.5.30" description = "Python package for providing Mozilla's CA Bundle." category = "dev" optional = false @@ -38,11 +38,15 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "click" -version = "7.1.2" +version = "8.0.1" description = "Composable command line interface toolkit" category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.6" + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" @@ -60,9 +64,6 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" -[package.dependencies] -toml = {version = "*", optional = true, markers = "extra == \"toml\""} - [package.extras] toml = ["toml"] @@ -118,17 +119,6 @@ flake8 = "*" [package.extras] test = ["coverage", "coveralls", "mock", "pytest", "pytest-cov"] -[[package]] -name = "flake8-coding" -version = "1.3.2" -description = "Adds coding magic comment checks to flake8" -category = "dev" -optional = false -python-versions = "*" - -[package.dependencies] -flake8 = "*" - [[package]] name = "flake8-commas" version = "2.0.0" @@ -274,7 +264,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "importlib-metadata" -version = "3.7.2" +version = "4.5.0" description = "Read metadata from Python packages" category = "main" optional = false @@ -286,7 +276,7 @@ zipp = ">=0.5" [package.extras] docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "pytest-enabler", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] +testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] [[package]] name = "iniconfig" @@ -298,7 +288,7 @@ python-versions = "*" [[package]] name = "isort" -version = "5.7.0" +version = "5.8.0" description = "A Python utility / library to sort Python imports." category = "dev" optional = false @@ -319,7 +309,7 @@ python-versions = "*" [[package]] name = "mypy" -version = "0.812" +version = "0.902" description = "Optional static typing for Python" category = "dev" optional = false @@ -327,11 +317,13 @@ python-versions = ">=3.5" [package.dependencies] mypy-extensions = ">=0.4.3,<0.5.0" -typed-ast = ">=1.4.0,<1.5.0" +toml = "*" +typed-ast = {version = ">=1.4.0,<1.5.0", markers = "python_version < \"3.8\""} typing-extensions = ">=3.7.4" [package.extras] dmypy = ["psutil (>=4.0)"] +python2 = ["typed-ast (>=1.4.0,<1.5.0)"] [[package]] name = "mypy-extensions" @@ -395,18 +387,21 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "pydocstyle" -version = "5.1.1" +version = "6.1.1" description = "Python docstring style checker" category = "dev" optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" [package.dependencies] snowballstemmer = "*" +[package.extras] +toml = ["toml"] + [[package]] name = "pyflakes" -version = "2.3.0" +version = "2.3.1" description = "passive checker of Python programs" category = "main" optional = false @@ -444,18 +439,19 @@ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xm [[package]] name = "pytest-cov" -version = "2.12.0" +version = "2.12.1" description = "Pytest plugin for measuring coverage." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.dependencies] -coverage = {version = ">=5.2.1", extras = ["toml"]} +coverage = ">=5.2.1" pytest = ">=4.6" +toml = "*" [package.extras] -testing = ["fields", "hunter", "process-tests (==2.0.2)", "six", "pytest-xdist", "virtualenv"] +testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"] [[package]] name = "pytest-randomly" @@ -511,7 +507,7 @@ requests = "*" [[package]] name = "six" -version = "1.15.0" +version = "1.16.0" description = "Python 2 and 3 compatibility utilities" category = "dev" optional = false @@ -548,15 +544,23 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "typed-ast" -version = "1.4.2" +version = "1.4.3" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false python-versions = "*" +[[package]] +name = "types-pkg-resources" +version = "0.1.3" +description = "Typing stubs for pkg_resources" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "typing-extensions" -version = "3.7.4.3" +version = "3.10.0.0" description = "Backported and Experimental Type Hints for Python 3.5+" category = "main" optional = false @@ -564,16 +568,16 @@ python-versions = "*" [[package]] name = "urllib3" -version = "1.26.4" +version = "1.26.5" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" [package.extras] +brotli = ["brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] -brotli = ["brotlipy (>=0.6.0)"] [[package]] name = "zipp" @@ -590,7 +594,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt [metadata] lock-version = "1.1" python-versions = "^3.6" -content-hash = "83436228d3a2eff88ea635084dcd3b768e1de40887c7c688805885220eae80b2" +content-hash = "4e7f76c5a473a213b375260643ed1e3835b13a38d005388437d69ed3f25d41a0" [metadata.files] atomicwrites = [ @@ -602,16 +606,16 @@ attrs = [ {file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"}, ] certifi = [ - {file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"}, - {file = "certifi-2020.12.5.tar.gz", hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"}, + {file = "certifi-2021.5.30-py2.py3-none-any.whl", hash = "sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8"}, + {file = "certifi-2021.5.30.tar.gz", hash = "sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee"}, ] chardet = [ {file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"}, {file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"}, ] click = [ - {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, - {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, + {file = "click-8.0.1-py3-none-any.whl", hash = "sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6"}, + {file = "click-8.0.1.tar.gz", hash = "sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a"}, ] colorama = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, @@ -686,10 +690,6 @@ flake8-builtins = [ {file = "flake8-builtins-1.5.3.tar.gz", hash = "sha256:09998853b2405e98e61d2ff3027c47033adbdc17f9fe44ca58443d876eb00f3b"}, {file = "flake8_builtins-1.5.3-py2.py3-none-any.whl", hash = "sha256:7706babee43879320376861897e5d1468e396a40b8918ed7bccf70e5f90b8687"}, ] -flake8-coding = [ - {file = "flake8-coding-1.3.2.tar.gz", hash = "sha256:b8f4d5157a8f74670e6cfea732c3d9f4291a4e994c8701d2c55f787c6e6cb741"}, - {file = "flake8_coding-1.3.2-py2.py3-none-any.whl", hash = "sha256:79704112c44d09d4ab6c8965e76a20c3f7073d52146db60303bce777d9612260"}, -] flake8-commas = [ {file = "flake8-commas-2.0.0.tar.gz", hash = "sha256:d3005899466f51380387df7151fb59afec666a0f4f4a2c6a8995b975de0f44b7"}, {file = "flake8_commas-2.0.0-py2.py3-none-any.whl", hash = "sha256:ee2141a3495ef9789a3894ed8802d03eff1eaaf98ce6d8653a7c573ef101935e"}, @@ -738,44 +738,45 @@ idna = [ {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, ] importlib-metadata = [ - {file = "importlib_metadata-3.7.2-py3-none-any.whl", hash = "sha256:407d13f55dc6f2a844e62325d18ad7019a436c4bfcaee34cda35f2be6e7c3e34"}, - {file = "importlib_metadata-3.7.2.tar.gz", hash = "sha256:18d5ff601069f98d5d605b6a4b50c18a34811d655c55548adc833e687289acde"}, + {file = "importlib_metadata-4.5.0-py3-none-any.whl", hash = "sha256:833b26fb89d5de469b24a390e9df088d4e52e4ba33b01dc5e0e4f41b81a16c00"}, + {file = "importlib_metadata-4.5.0.tar.gz", hash = "sha256:b142cc1dd1342f31ff04bb7d022492b09920cb64fed867cd3ea6f80fe3ebd139"}, ] iniconfig = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, ] isort = [ - {file = "isort-5.7.0-py3-none-any.whl", hash = "sha256:fff4f0c04e1825522ce6949973e83110a6e907750cd92d128b0d14aaaadbffdc"}, - {file = "isort-5.7.0.tar.gz", hash = "sha256:c729845434366216d320e936b8ad6f9d681aab72dc7cbc2d51bedc3582f3ad1e"}, + {file = "isort-5.8.0-py3-none-any.whl", hash = "sha256:2bb1680aad211e3c9944dbce1d4ba09a989f04e238296c87fe2139faa26d655d"}, + {file = "isort-5.8.0.tar.gz", hash = "sha256:0a943902919f65c5684ac4e0154b1ad4fac6dcaa5d9f3426b732f1c8b5419be6"}, ] mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] mypy = [ - {file = "mypy-0.812-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:a26f8ec704e5a7423c8824d425086705e381b4f1dfdef6e3a1edab7ba174ec49"}, - {file = "mypy-0.812-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:28fb5479c494b1bab244620685e2eb3c3f988d71fd5d64cc753195e8ed53df7c"}, - {file = "mypy-0.812-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:9743c91088d396c1a5a3c9978354b61b0382b4e3c440ce83cf77994a43e8c521"}, - {file = "mypy-0.812-cp35-cp35m-win_amd64.whl", hash = "sha256:d7da2e1d5f558c37d6e8c1246f1aec1e7349e4913d8fb3cb289a35de573fe2eb"}, - {file = "mypy-0.812-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:4eec37370483331d13514c3f55f446fc5248d6373e7029a29ecb7b7494851e7a"}, - {file = "mypy-0.812-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:d65cc1df038ef55a99e617431f0553cd77763869eebdf9042403e16089fe746c"}, - {file = "mypy-0.812-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:61a3d5b97955422964be6b3baf05ff2ce7f26f52c85dd88db11d5e03e146a3a6"}, - {file = "mypy-0.812-cp36-cp36m-win_amd64.whl", hash = "sha256:25adde9b862f8f9aac9d2d11971f226bd4c8fbaa89fb76bdadb267ef22d10064"}, - {file = "mypy-0.812-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:552a815579aa1e995f39fd05dde6cd378e191b063f031f2acfe73ce9fb7f9e56"}, - {file = "mypy-0.812-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:499c798053cdebcaa916eef8cd733e5584b5909f789de856b482cd7d069bdad8"}, - {file = "mypy-0.812-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:5873888fff1c7cf5b71efbe80e0e73153fe9212fafdf8e44adfe4c20ec9f82d7"}, - {file = "mypy-0.812-cp37-cp37m-win_amd64.whl", hash = "sha256:9f94aac67a2045ec719ffe6111df543bac7874cee01f41928f6969756e030564"}, - {file = "mypy-0.812-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d23e0ea196702d918b60c8288561e722bf437d82cb7ef2edcd98cfa38905d506"}, - {file = "mypy-0.812-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:674e822aa665b9fd75130c6c5f5ed9564a38c6cea6a6432ce47eafb68ee578c5"}, - {file = "mypy-0.812-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:abf7e0c3cf117c44d9285cc6128856106183938c68fd4944763003decdcfeb66"}, - {file = "mypy-0.812-cp38-cp38-win_amd64.whl", hash = "sha256:0d0a87c0e7e3a9becdfbe936c981d32e5ee0ccda3e0f07e1ef2c3d1a817cf73e"}, - {file = "mypy-0.812-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7ce3175801d0ae5fdfa79b4f0cfed08807af4d075b402b7e294e6aa72af9aa2a"}, - {file = "mypy-0.812-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:b09669bcda124e83708f34a94606e01b614fa71931d356c1f1a5297ba11f110a"}, - {file = "mypy-0.812-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:33f159443db0829d16f0a8d83d94df3109bb6dd801975fe86bacb9bf71628e97"}, - {file = "mypy-0.812-cp39-cp39-win_amd64.whl", hash = "sha256:3f2aca7f68580dc2508289c729bd49ee929a436208d2b2b6aab15745a70a57df"}, - {file = "mypy-0.812-py3-none-any.whl", hash = "sha256:2f9b3407c58347a452fc0736861593e105139b905cca7d097e413453a1d650b4"}, - {file = "mypy-0.812.tar.gz", hash = "sha256:cd07039aa5df222037005b08fbbfd69b3ab0b0bd7a07d7906de75ae52c4e3119"}, + {file = "mypy-0.902-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:3f12705eabdd274b98f676e3e5a89f247ea86dc1af48a2d5a2b080abac4e1243"}, + {file = "mypy-0.902-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:2f9fedc1f186697fda191e634ac1d02f03d4c260212ccb018fabbb6d4b03eee8"}, + {file = "mypy-0.902-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:0756529da2dd4d53d26096b7969ce0a47997123261a5432b48cc6848a2cb0bd4"}, + {file = "mypy-0.902-cp35-cp35m-win_amd64.whl", hash = "sha256:68a098c104ae2b75e946b107ef69dd8398d54cb52ad57580dfb9fc78f7f997f0"}, + {file = "mypy-0.902-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cd01c599cf9f897b6b6c6b5d8b182557fb7d99326bcdf5d449a0fbbb4ccee4b9"}, + {file = "mypy-0.902-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:e89880168c67cf4fde4506b80ee42f1537ad66ad366c101d388b3fd7d7ce2afd"}, + {file = "mypy-0.902-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:ebe2bc9cb638475f5d39068d2dbe8ae1d605bb8d8d3ff281c695df1670ab3987"}, + {file = "mypy-0.902-cp36-cp36m-win_amd64.whl", hash = "sha256:f89bfda7f0f66b789792ab64ce0978e4a991a0e4dd6197349d0767b0f1095b21"}, + {file = "mypy-0.902-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:746e0b0101b8efec34902810047f26a8c80e1efbb4fc554956d848c05ef85d76"}, + {file = "mypy-0.902-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:0190fb77e93ce971954c9e54ea61de2802065174e5e990c9d4c1d0f54fbeeca2"}, + {file = "mypy-0.902-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:b5dfcd22c6bab08dfeded8d5b44bdcb68c6f1ab261861e35c470b89074f78a70"}, + {file = "mypy-0.902-cp37-cp37m-win_amd64.whl", hash = "sha256:b5ba1f0d5f9087e03bf5958c28d421a03a4c1ad260bf81556195dffeccd979c4"}, + {file = "mypy-0.902-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9ef5355eaaf7a23ab157c21a44c614365238a7bdb3552ec3b80c393697d974e1"}, + {file = "mypy-0.902-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:517e7528d1be7e187a5db7f0a3e479747307c1b897d9706b1c662014faba3116"}, + {file = "mypy-0.902-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:fd634bc17b1e2d6ce716f0e43446d0d61cdadb1efcad5c56ca211c22b246ebc8"}, + {file = "mypy-0.902-cp38-cp38-win_amd64.whl", hash = "sha256:fc4d63da57ef0e8cd4ab45131f3fe5c286ce7dd7f032650d0fbc239c6190e167"}, + {file = "mypy-0.902-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:353aac2ce41ddeaf7599f1c73fed2b75750bef3b44b6ad12985a991bc002a0da"}, + {file = "mypy-0.902-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ae94c31bb556ddb2310e4f913b706696ccbd43c62d3331cd3511caef466871d2"}, + {file = "mypy-0.902-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:8be7bbd091886bde9fcafed8dd089a766fa76eb223135fe5c9e9798f78023a20"}, + {file = "mypy-0.902-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:4efc67b9b3e2fddbe395700f91d5b8deb5980bfaaccb77b306310bd0b9e002eb"}, + {file = "mypy-0.902-cp39-cp39-win_amd64.whl", hash = "sha256:9f1d74eeb3f58c7bd3f3f92b8f63cb1678466a55e2c4612bf36909105d0724ab"}, + {file = "mypy-0.902-py3-none-any.whl", hash = "sha256:a26d0e53e90815c765f91966442775cf03b8a7514a4e960de7b5320208b07269"}, + {file = "mypy-0.902.tar.gz", hash = "sha256:9236c21194fde5df1b4d8ebc2ef2c1f2a5dc7f18bcbea54274937cae2e20a01c"}, ] mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, @@ -802,12 +803,12 @@ pycodestyle = [ {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, ] pydocstyle = [ - {file = "pydocstyle-5.1.1-py3-none-any.whl", hash = "sha256:aca749e190a01726a4fb472dd4ef23b5c9da7b9205c0a7857c06533de13fd678"}, - {file = "pydocstyle-5.1.1.tar.gz", hash = "sha256:19b86fa8617ed916776a11cd8bc0197e5b9856d5433b777f51a3defe13075325"}, + {file = "pydocstyle-6.1.1-py3-none-any.whl", hash = "sha256:6987826d6775056839940041beef5c08cc7e3d71d63149b48e36727f70144dc4"}, + {file = "pydocstyle-6.1.1.tar.gz", hash = "sha256:1d41b7c459ba0ee6c345f2eb9ae827cab14a7533a88c5c6f7e94923f72df92dc"}, ] pyflakes = [ - {file = "pyflakes-2.3.0-py2.py3-none-any.whl", hash = "sha256:910208209dcea632721cb58363d0f72913d9e8cf64dc6f8ae2e02a3609aba40d"}, - {file = "pyflakes-2.3.0.tar.gz", hash = "sha256:e59fd8e750e588358f1b8885e5a4751203a0516e0ee6d34811089ac294c8806f"}, + {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"}, + {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"}, ] pyparsing = [ {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, @@ -818,8 +819,8 @@ pytest = [ {file = "pytest-6.2.4.tar.gz", hash = "sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b"}, ] pytest-cov = [ - {file = "pytest-cov-2.12.0.tar.gz", hash = "sha256:8535764137fecce504a49c2b742288e3d34bc09eed298ad65963616cc98fd45e"}, - {file = "pytest_cov-2.12.0-py2.py3-none-any.whl", hash = "sha256:95d4933dcbbacfa377bb60b29801daa30d90c33981ab2a79e9ab4452c165066e"}, + {file = "pytest-cov-2.12.1.tar.gz", hash = "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"}, + {file = "pytest_cov-2.12.1-py2.py3-none-any.whl", hash = "sha256:261bb9e47e65bd099c89c3edf92972865210c36813f80ede5277dceb77a4a62a"}, ] pytest-randomly = [ {file = "pytest-randomly-3.8.0.tar.gz", hash = "sha256:d9e21a72446757129378beea00bc9a32df1fb1cfd0bbe408be1ae9685bdf1209"}, @@ -865,8 +866,8 @@ safety = [ {file = "safety-1.10.3.tar.gz", hash = "sha256:30e394d02a20ac49b7f65292d19d38fa927a8f9582cdfd3ad1adbbc66c641ad5"}, ] six = [ - {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, - {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] snowballstemmer = [ {file = "snowballstemmer-2.1.0-py2.py3-none-any.whl", hash = "sha256:b51b447bea85f9968c13b650126a888aabd4cb4463fca868ec596826325dedc2"}, @@ -881,45 +882,49 @@ toml = [ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] typed-ast = [ - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:7703620125e4fb79b64aa52427ec192822e9f45d37d4b6625ab37ef403e1df70"}, - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c9aadc4924d4b5799112837b226160428524a9a45f830e0d0f184b19e4090487"}, - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:9ec45db0c766f196ae629e509f059ff05fc3148f9ffd28f3cfe75d4afb485412"}, - {file = "typed_ast-1.4.2-cp35-cp35m-win32.whl", hash = "sha256:85f95aa97a35bdb2f2f7d10ec5bbdac0aeb9dafdaf88e17492da0504de2e6400"}, - {file = "typed_ast-1.4.2-cp35-cp35m-win_amd64.whl", hash = "sha256:9044ef2df88d7f33692ae3f18d3be63dec69c4fb1b5a4a9ac950f9b4ba571606"}, - {file = "typed_ast-1.4.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:c1c876fd795b36126f773db9cbb393f19808edd2637e00fd6caba0e25f2c7b64"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:5dcfc2e264bd8a1db8b11a892bd1647154ce03eeba94b461effe68790d8b8e07"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:8db0e856712f79c45956da0c9a40ca4246abc3485ae0d7ecc86a20f5e4c09abc"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:d003156bb6a59cda9050e983441b7fa2487f7800d76bdc065566b7d728b4581a"}, - {file = "typed_ast-1.4.2-cp36-cp36m-win32.whl", hash = "sha256:4c790331247081ea7c632a76d5b2a265e6d325ecd3179d06e9cf8d46d90dd151"}, - {file = "typed_ast-1.4.2-cp36-cp36m-win_amd64.whl", hash = "sha256:d175297e9533d8d37437abc14e8a83cbc68af93cc9c1c59c2c292ec59a0697a3"}, - {file = "typed_ast-1.4.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf54cfa843f297991b7388c281cb3855d911137223c6b6d2dd82a47ae5125a41"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:b4fcdcfa302538f70929eb7b392f536a237cbe2ed9cba88e3bf5027b39f5f77f"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:987f15737aba2ab5f3928c617ccf1ce412e2e321c77ab16ca5a293e7bbffd581"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:37f48d46d733d57cc70fd5f30572d11ab8ed92da6e6b28e024e4a3edfb456e37"}, - {file = "typed_ast-1.4.2-cp37-cp37m-win32.whl", hash = "sha256:36d829b31ab67d6fcb30e185ec996e1f72b892255a745d3a82138c97d21ed1cd"}, - {file = "typed_ast-1.4.2-cp37-cp37m-win_amd64.whl", hash = "sha256:8368f83e93c7156ccd40e49a783a6a6850ca25b556c0fa0240ed0f659d2fe496"}, - {file = "typed_ast-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:963c80b583b0661918718b095e02303d8078950b26cc00b5e5ea9ababe0de1fc"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e683e409e5c45d5c9082dc1daf13f6374300806240719f95dc783d1fc942af10"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:84aa6223d71012c68d577c83f4e7db50d11d6b1399a9c779046d75e24bed74ea"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:a38878a223bdd37c9709d07cd357bb79f4c760b29210e14ad0fb395294583787"}, - {file = "typed_ast-1.4.2-cp38-cp38-win32.whl", hash = "sha256:a2c927c49f2029291fbabd673d51a2180038f8cd5a5b2f290f78c4516be48be2"}, - {file = "typed_ast-1.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:c0c74e5579af4b977c8b932f40a5464764b2f86681327410aa028a22d2f54937"}, - {file = "typed_ast-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:07d49388d5bf7e863f7fa2f124b1b1d89d8aa0e2f7812faff0a5658c01c59aa1"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux1_i686.whl", hash = "sha256:240296b27397e4e37874abb1df2a608a92df85cf3e2a04d0d4d61055c8305ba6"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:d746a437cdbca200622385305aedd9aef68e8a645e385cc483bdc5e488f07166"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:14bf1522cdee369e8f5581238edac09150c765ec1cb33615855889cf33dcb92d"}, - {file = "typed_ast-1.4.2-cp39-cp39-win32.whl", hash = "sha256:cc7b98bf58167b7f2db91a4327da24fb93368838eb84a44c472283778fc2446b"}, - {file = "typed_ast-1.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:7147e2a76c75f0f64c4319886e7639e490fee87c9d25cb1d4faef1d8cf83a440"}, - {file = "typed_ast-1.4.2.tar.gz", hash = "sha256:9fc0b3cb5d1720e7141d103cf4819aea239f7d136acf9ee4a69b047b7986175a"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, + {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, + {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, + {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, + {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, + {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, + {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, + {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, + {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, + {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, +] +types-pkg-resources = [ + {file = "types-pkg_resources-0.1.3.tar.gz", hash = "sha256:834a9b8d3dbea343562fd99d5d3359a726f6bf9d3733bccd2b4f3096fbab9dae"}, + {file = "types_pkg_resources-0.1.3-py2.py3-none-any.whl", hash = "sha256:0cb9972cee992249f93fff1a491bf2dc3ce674e5a1926e27d4f0866f7d9b6d9c"}, ] typing-extensions = [ - {file = "typing_extensions-3.7.4.3-py2-none-any.whl", hash = "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"}, - {file = "typing_extensions-3.7.4.3-py3-none-any.whl", hash = "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918"}, - {file = "typing_extensions-3.7.4.3.tar.gz", hash = "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c"}, + {file = "typing_extensions-3.10.0.0-py2-none-any.whl", hash = "sha256:0ac0f89795dd19de6b97debb0c6af1c70987fd80a2d62d1958f7e56fcc31b497"}, + {file = "typing_extensions-3.10.0.0-py3-none-any.whl", hash = "sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84"}, + {file = "typing_extensions-3.10.0.0.tar.gz", hash = "sha256:50b6f157849174217d0656f99dc82fe932884fb250826c18350e159ec6cdf342"}, ] urllib3 = [ - {file = "urllib3-1.26.4-py2.py3-none-any.whl", hash = "sha256:2f4da4594db7e1e110a944bb1b551fdf4e6c136ad42e4234131391e21eb5b0df"}, - {file = "urllib3-1.26.4.tar.gz", hash = "sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937"}, + {file = "urllib3-1.26.5-py2.py3-none-any.whl", hash = "sha256:753a0374df26658f99d826cfe40394a686d05985786d946fbe4165b5148f5a7c"}, + {file = "urllib3-1.26.5.tar.gz", hash = "sha256:a7acd0977125325f516bda9735fa7142b909a8d01e8b2e4c8108d0984e6e0098"}, ] zipp = [ {file = "zipp-3.4.1-py3-none-any.whl", hash = "sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098"}, diff --git a/pyproject.toml b/pyproject.toml index bb66a7f..a4b8515 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,14 +59,15 @@ flake8-quotes = "^3.2" flake8-comprehensions = "^3.5" flake8-docstrings = "^1.6" flake8-string-format = "^0.3" -flake8-coding = "^1.3" flake8-pep3101 = "^1.3" flake8-super-call = "^1.0" flake8-debugger = "^4.0" flake8-isort = "^4.0" pep8-naming = "^0.11" -mypy = "^0.812" +mypy = "^0.902" +types-pkg-resources = "^0.1.3" + safety = "^1.10" zipp = "3.4.1" diff --git a/tests/conftest.py b/tests/conftest.py index 031b877..8f84941 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- - - import os +import tokenize +from typing import List import pytest @@ -12,5 +11,22 @@ def absolute_path(): def factory(*files): dirname = os.path.dirname(__file__) return os.path.join(dirname, *files) + return factory + +@pytest.fixture(scope='session') +def get_file_tokens(): + """Fixture to generate tokens for a given filename.""" + def factory(filename: str) -> List[tokenize.TokenInfo]: + with open(filename) as file_obj: + return list(tokenize.generate_tokens(file_obj.readline)) + return factory + + +@pytest.fixture(scope='session') +def get_file_lines(): + """Fixture to read file into a sequence of lines for a given filename.""" + def factory(filename: str) -> List[str]: + with open(filename) as file_obj: + return file_obj.readlines() return factory diff --git a/tests/test_comments.py b/tests/test_comments.py index 188b7ee..3eb2faa 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -1,8 +1,5 @@ -# -*- coding: utf-8 -*- - import subprocess import sys -import tokenize from collections import namedtuple from flake8_eradicate import Checker @@ -10,11 +7,6 @@ PY_GTE_36 = sys.version_info >= (3, 6) -def _get_file_tokens(filename: str): - with open(filename) as f: - return list(tokenize.generate_tokens(f.readline)) - - def test_correct_fixture(absolute_path): """End-to-End test to check that correct code works.""" filename = absolute_path('fixtures', 'correct.py') @@ -136,7 +128,11 @@ def test_incorrect_fixture_whitelist_extend(absolute_path): assert b'# typed_property: int = 10' in stdout -def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): +def test_lines_with_commented_out_code_incorrect_fixture_output( + absolute_path, + get_file_lines, + get_file_tokens, +): """Verify central underlying method is returning correct output.""" filename = absolute_path('fixtures', 'incorrect.py') @@ -152,8 +148,8 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): checker = Checker( tree=None, - filename=filename, - file_tokens=_get_file_tokens(filename), + lines=get_file_lines(filename), + file_tokens=get_file_tokens(filename), ) output = list(checker._lines_with_commented_out_code()) if PY_GTE_36: @@ -164,6 +160,8 @@ def test_lines_with_commented_out_code_incorrect_fixture_output(absolute_path): def test_lines_with_commented_out_code_file_no_comment( absolute_path, + get_file_tokens, + get_file_lines, ): """Make sure file without comment are ignored.""" filename = absolute_path('fixtures', 'correct_no_comment.py') @@ -180,8 +178,8 @@ def test_lines_with_commented_out_code_file_no_comment( checker = Checker( tree=None, - filename=filename, - file_tokens=_get_file_tokens(filename), + lines=get_file_lines(filename), + file_tokens=get_file_tokens(filename), ) output = list(checker._lines_with_commented_out_code()) assert output == [] diff --git a/tests/test_version.py b/tests/test_version.py index 3df71e1..e8b9661 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import subprocess from flake8_eradicate import pkg_name, pkg_version