From aa002ee4ed7fcb4c6ffdec29b4dc122244638c64 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 18 Nov 2022 11:32:13 -0500 Subject: [PATCH] require python 3.8.1+ --- .github/workflows/main.yml | 18 +++---- .pre-commit-config.yaml | 4 +- setup.cfg | 8 +-- src/flake8/_compat.py | 18 ------- src/flake8/plugins/finder.py | 14 ++--- tests/integration/test_checker.py | 4 +- tests/integration/test_main.py | 2 - tests/unit/plugins/finder_test.py | 82 ++++++++++++++--------------- tests/unit/plugins/reporter_test.py | 4 +- tests/unit/test_debug.py | 4 +- tests/unit/test_file_checker.py | 4 +- tox.ini | 2 +- 12 files changed, 70 insertions(+), 94 deletions(-) delete mode 100644 src/flake8/_compat.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 868b5ea9..e5799e1c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,10 +13,7 @@ jobs: include: # linux - os: ubuntu-latest - python: pypy-3.7 - toxenv: py - - os: ubuntu-latest - python: 3.7 + python: pypy-3.8 toxenv: py - os: ubuntu-latest python: 3.8 @@ -25,21 +22,24 @@ jobs: python: 3.9 toxenv: py - os: ubuntu-latest - python: '3.10.0-alpha - 3.10.999' + python: '3.10' + toxenv: py + - os: ubuntu-latest + python: '3.11' toxenv: py # windows - os: windows-latest - python: 3.7 + python: 3.8 toxenv: py # misc - os: ubuntu-latest - python: 3.9 + python: '3.10' toxenv: docs - os: ubuntu-latest - python: 3.9 + python: '3.10' toxenv: linters - os: ubuntu-latest - python: 3.9 + python: '3.10' toxenv: dogfood runs-on: ${{ matrix.os }} steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e602e1e..10914b71 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,14 +13,14 @@ repos: - id: reorder-python-imports args: [ --application-directories, '.:src', - --py37-plus, + --py38-plus, --add-import, 'from __future__ import annotations', ] - repo: https://github.com/asottile/pyupgrade rev: v3.2.2 hooks: - id: pyupgrade - args: [--py37-plus] + args: [--py38-plus] - repo: https://github.com/psf/black rev: 22.10.0 hooks: diff --git a/setup.cfg b/setup.cfg index 5e20adf6..36e90b4e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,10 +20,6 @@ classifiers = Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Libraries :: Python Modules @@ -41,8 +37,8 @@ install_requires = mccabe>=0.7.0,<0.8.0 pycodestyle>=2.9.0,<2.10.0 pyflakes>=2.5.0,<2.6.0 - importlib-metadata>=1.1.0,<4.3;python_version<"3.8" -python_requires = >=3.7 +# 3.8.0's importlib.metadata is broken +python_requires = >=3.8.1 [options.packages.find] where = src diff --git a/src/flake8/_compat.py b/src/flake8/_compat.py deleted file mode 100644 index 91770bc3..00000000 --- a/src/flake8/_compat.py +++ /dev/null @@ -1,18 +0,0 @@ -"""Expose backports in a single place.""" -from __future__ import annotations - -import sys - -if sys.version_info >= (3, 8): # pragma: no cover (PY38+) - import importlib.metadata as importlib_metadata -else: # pragma: no cover ( Generator[Plugin, None, None]: - pyflakes_meta = importlib_metadata.distribution("pyflakes").metadata - pycodestyle_meta = importlib_metadata.distribution("pycodestyle").metadata + pyflakes_meta = importlib.metadata.distribution("pyflakes").metadata + pycodestyle_meta = importlib.metadata.distribution("pycodestyle").metadata for ep in eps: if ep.group not in FLAKE8_GROUPS: @@ -176,7 +176,7 @@ def _flake8_plugins( def _find_importlib_plugins() -> Generator[Plugin, None, None]: # some misconfigured pythons (RHEL) have things on `sys.path` twice seen = set() - for dist in importlib_metadata.distributions(): + for dist in importlib.metadata.distributions(): # assigned to prevent continual reparsing eps = dist.entry_points @@ -221,7 +221,7 @@ def _find_local_plugins( ): name, _, entry_str = plugin_s.partition("=") name, entry_str = name.strip(), entry_str.strip() - ep = importlib_metadata.EntryPoint(name, entry_str, group) + ep = importlib.metadata.EntryPoint(name, entry_str, group) yield Plugin("local", "local", ep) diff --git a/tests/integration/test_checker.py b/tests/integration/test_checker.py index 13ec8c1e..a585f5ac 100644 --- a/tests/integration/test_checker.py +++ b/tests/integration/test_checker.py @@ -1,13 +1,13 @@ """Integration tests for the checker submodule.""" from __future__ import annotations +import importlib.metadata import sys from unittest import mock import pytest from flake8 import checker -from flake8._compat import importlib_metadata from flake8.plugins import finder from flake8.processor import FileProcessor @@ -85,7 +85,7 @@ def mock_file_checker_with_plugin(plugin_target): finder.Plugin( "flake-package", "9001", - importlib_metadata.EntryPoint( + importlib.metadata.EntryPoint( "Q", f"{plugin_target.__module__}:{plugin_target.__name__}", "flake8.extension", diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index 96d1182d..68b93cb3 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -170,8 +170,6 @@ def test_tokenization_error_but_not_syntax_error(tmpdir, capsys): if hasattr(sys, "pypy_version_info"): # pragma: no cover (pypy) expected = "t.py:2:1: E999 SyntaxError: end of file (EOF) in multi-line statement\n" # noqa: E501 - elif sys.version_info < (3, 8): # pragma: no cover (