Skip to content

Commit

Permalink
Merge pull request pytest-dev#427 from bluetech/drop-py37
Browse files Browse the repository at this point in the history
Remove support for Python 3.7
  • Loading branch information
bluetech authored Aug 3, 2023
2 parents c8b59d6 + 9a21725 commit b41572e
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 69 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ jobs:
fail-fast: false
matrix:
name: [
"windows-py37",
"windows-py38",
"windows-py311",
"windows-pypy3",

"ubuntu-py38-pytestmain",
"ubuntu-py37",
"ubuntu-py38",
"ubuntu-py39",
"ubuntu-py310",
Expand All @@ -35,10 +34,10 @@ jobs:
]

include:
- name: "windows-py37"
python: "3.7"
- name: "windows-py38"
python: "3.8"
os: windows-latest
tox_env: "py37"
tox_env: "py38"
- name: "windows-py311"
python: "3.10"
os: windows-latest
Expand All @@ -47,11 +46,6 @@ jobs:
python: "pypy3.9"
os: windows-latest
tox_env: "pypy3"
- name: "ubuntu-py37"
python: "3.7"
os: ubuntu-latest
tox_env: "py37"
use_coverage: true
- name: "ubuntu-py38"
python: "3.8"
os: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
rev: v3.10.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src', --py37-plus]
args: ['--application-directories=.:src', --py38-plus]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
Expand All @@ -27,7 +27,7 @@ repos:
rev: v3.10.1
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand Down
12 changes: 12 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

python:
install:
# Without this, sphinx can't find pluggy's version.
- method: pip
path: .

build:
os: ubuntu-22.04
tools:
python: "3.11"
1 change: 1 addition & 0 deletions changelog/426.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.7 is no longer supported.
7 changes: 1 addition & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import sys
from importlib import metadata
from typing import TYPE_CHECKING

if TYPE_CHECKING:
import sphinx.application

if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata


extensions = [
"sphinx.ext.autodoc",
Expand Down
5 changes: 1 addition & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ classifiers =
Programming Language :: Python :: Implementation :: PyPy
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
Expand All @@ -31,9 +30,7 @@ classifiers =
[options]
packages =
pluggy
install_requires =
importlib-metadata>=0.12;python_version<"3.8"
python_requires = >=3.7
python_requires = >=3.8
package_dir =
=src
setup_requires =
Expand Down
5 changes: 1 addition & 4 deletions src/pluggy/_callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
from typing import Mapping
from typing import Sequence
from typing import Tuple
from typing import TYPE_CHECKING
from typing import Union

from ._hooks import HookImpl
from ._result import _raise_wrapfail
from ._result import _Result
from ._result import HookCallError

if TYPE_CHECKING:
from ._hooks import HookImpl


# Need to distinguish between old- and new-style hook wrappers.
# Wrapping one a singleton tuple is the fastest type-safe way I found to do it.
Expand Down
35 changes: 17 additions & 18 deletions src/pluggy/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import AbstractSet
from typing import Any
from typing import Callable
from typing import Final
from typing import Generator
from typing import List
from typing import Mapping
Expand All @@ -18,15 +19,12 @@
from typing import Sequence
from typing import Tuple
from typing import TYPE_CHECKING
from typing import TypedDict
from typing import TypeVar
from typing import Union

from ._result import _Result

if TYPE_CHECKING:
from typing_extensions import TypedDict
from typing_extensions import Final


_T = TypeVar("_T")
_F = TypeVar("_F", bound=Callable[..., object])
Expand All @@ -37,20 +35,21 @@
Union[object, List[object]],
]
_HookImplFunction = Callable[..., Union[_T, Generator[None, _Result[_T], None]]]
if TYPE_CHECKING:

class _HookSpecOpts(TypedDict):
firstresult: bool
historic: bool
warn_on_impl: Warning | None

class _HookImplOpts(TypedDict):
wrapper: bool
hookwrapper: bool
optionalhook: bool
tryfirst: bool
trylast: bool
specname: str | None


class _HookSpecOpts(TypedDict):
firstresult: bool
historic: bool
warn_on_impl: Warning | None


class _HookImplOpts(TypedDict):
wrapper: bool
hookwrapper: bool
optionalhook: bool
tryfirst: bool
trylast: bool
specname: str | None


class HookspecMarker:
Expand Down
19 changes: 6 additions & 13 deletions src/pluggy/_manager.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
from __future__ import annotations

import importlib.metadata
import inspect
import sys
import types
import warnings
from typing import Any
from typing import Callable
from typing import cast
from typing import Final
from typing import Iterable
from typing import Mapping
from typing import Sequence
from typing import TYPE_CHECKING

from . import _tracing
from ._callers import _multicall
from ._hooks import _HookCaller
from ._hooks import _HookImplFunction
from ._hooks import _HookImplOpts
from ._hooks import _HookRelay
from ._hooks import _HookSpecOpts
from ._hooks import _Namespace
from ._hooks import _Plugin
from ._hooks import _SubsetHookCaller
Expand All @@ -25,15 +27,6 @@
from ._hooks import normalize_hookimpl_opts
from ._result import _Result

if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata
else:
import importlib_metadata

if TYPE_CHECKING:
from typing_extensions import Final

from ._hooks import _HookImplOpts, _HookSpecOpts

_BeforeTrace = Callable[[str, Sequence[HookImpl], Mapping[str, Any]], None]
_AfterTrace = Callable[[_Result[Any], str, Sequence[HookImpl], Mapping[str, Any]], None]
Expand Down Expand Up @@ -63,7 +56,7 @@ def __init__(self, plugin: _Plugin, message: str) -> None:
class DistFacade:
"""Emulate a pkg_resources Distribution"""

def __init__(self, dist: importlib_metadata.Distribution) -> None:
def __init__(self, dist: importlib.metadata.Distribution) -> None:
self._dist = dist

@property
Expand Down Expand Up @@ -351,7 +344,7 @@ def load_setuptools_entrypoints(self, group: str, name: str | None = None) -> in
:return: The number of plugins loaded by this call.
"""
count = 0
for dist in list(importlib_metadata.distributions()):
for dist in list(importlib.metadata.distributions()):
for ep in dist.entry_points:
if (
ep.group != group
Expand Down
5 changes: 1 addition & 4 deletions src/pluggy/_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
from typing import cast
from typing import Generator
from typing import Generic
from typing import NoReturn
from typing import Optional
from typing import Tuple
from typing import Type
from typing import TYPE_CHECKING
from typing import TypeVar

if TYPE_CHECKING:
from typing import NoReturn


_ExcInfo = Tuple[Type[BaseException], BaseException, Optional[TracebackType]]
_T = TypeVar("_T")
Expand Down
9 changes: 2 additions & 7 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
``PluginManager`` unit and public API testing.
"""
import sys
import importlib.metadata
from typing import Any
from typing import List

Expand All @@ -13,11 +13,6 @@
from pluggy import PluginManager
from pluggy import PluginValidationError

if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata
else:
import importlib_metadata


hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")
Expand Down Expand Up @@ -590,7 +585,7 @@ class Distribution:
def my_distributions():
return (dist,)

monkeypatch.setattr(importlib_metadata, "distributions", my_distributions)
monkeypatch.setattr(importlib.metadata, "distributions", my_distributions)
num = pm.load_setuptools_entrypoints("hello")
assert num == 1
plugin = pm.get_plugin("myname")
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=linting,docs,py{37,38,39,310,311,py3},py{38}-pytest{main}
envlist=docs,py{38,39,310,311,py3},py{38}-pytest{main}

[testenv]
commands=
Expand Down

0 comments on commit b41572e

Please sign in to comment.