Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 3.8 support as it has reached EOL #1036

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ jobs:
- 3.11
- "3.10"
- 3.9
- 3.8
no-extensions: ['', 'Y']
os: [ubuntu, macos, windows]
exclude:
Expand All @@ -169,7 +168,7 @@ jobs:
- os: windows
pyver: 3.13-freethreading # this is still tested within cibuildwheel
include:
- pyver: pypy-3.8
- pyver: pypy-3.9
no-extensions: Y
os: ubuntu
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ jobs:
token: ${{ secrets.codecov-token }}
files: >-
.tox/.tmp/.mypy/python-3.13/cobertura.xml,
.tox/.tmp/.mypy/python-3.12/cobertura.xml
.tox/.tmp/.mypy/python-3.11/cobertura.xml,
.tox/.tmp/.mypy/python-3.9/cobertura.xml,
.tox/.tmp/.mypy/python-3.8/cobertura.xml
flags: >-
CI-GHA,
MyPy
Expand Down
36 changes: 18 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,37 @@ repos:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- pytest-codspeed == 2.2.1
- Sphinx >= 5.3.0
args:
- --python-version=3.13
- --txt-report=.tox/.tmp/.mypy/python-3.13
- --cobertura-xml-report=.tox/.tmp/.mypy/python-3.13
- --html-report=.tox/.tmp/.mypy/python-3.13
pass_filenames: false
- id: mypy
alias: mypy-py312
name: MyPy, for Python 3.12
additional_dependencies:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest-codspeed == 2.2.1
- Sphinx >= 5.3.0
args:
- --python-version=3.12
- --txt-report=.tox/.tmp/.mypy/python-3.12
- --cobertura-xml-report=.tox/.tmp/.mypy/python-3.12
- --html-report=.tox/.tmp/.mypy/python-3.12
pass_filenames: false
- id: mypy
alias: mypy-py311
name: MyPy, for Python 3.11
additional_dependencies:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- pytest-codspeed == 2.2.1
- Sphinx >= 5.3.0
args:
- --python-version=3.11
Expand All @@ -144,28 +159,13 @@ repos:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- pytest-codspeed == 2.2.1
- Sphinx >= 5.3.0
args:
- --python-version=3.9
- --txt-report=.tox/.tmp/.mypy/python-3.9
- --cobertura-xml-report=.tox/.tmp/.mypy/python-3.9
- --html-report=.tox/.tmp/.mypy/python-3.9
pass_filenames: false
- id: mypy
alias: mypy-py38
name: MyPy, for Python 3.8
additional_dependencies:
- types-docutils
- lxml # dep of `--txt-report`, `--cobertura-xml-report` & `--html-report`
- pytest
- pytest_codspeed
- Sphinx >= 5.3.0
args:
- --python-version=3.8
- --txt-report=.tox/.tmp/.mypy/python-3.8
- --cobertura-xml-report=.tox/.tmp/.mypy/python-3.8
- --html-report=.tox/.tmp/.mypy/python-3.8
pass_filenames: false

...
1 change: 1 addition & 0 deletions CHANGES/1036.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped Python 3.8 support as it has reached EOL -- by :user:`bdraco`.
12 changes: 2 additions & 10 deletions multidict/_abc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import abc
import sys
import types
from collections.abc import Mapping, MutableMapping

Expand All @@ -9,15 +8,8 @@ class _TypingMeta(abc.ABCMeta):
# basically MultiMapping[str] and other generic-like type instantiations
# are emulated.
# Note: real type hints are provided by __init__.pyi stub file
if sys.version_info >= (3, 9):

def __getitem__(self, key):
return types.GenericAlias(self, key)

else:

def __getitem__(self, key):
return self
def __getitem__(self, key):
return types.GenericAlias(self, key)


class MultiMapping(Mapping, metaclass=_TypingMeta):
Expand Down
23 changes: 0 additions & 23 deletions multidict/_multidict.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,21 +775,13 @@ static inline void
multidict_tp_dealloc(MultiDictObject *self)
{
PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_TRASHCAN_BEGIN(self, multidict_tp_dealloc)
#else
Py_TRASHCAN_SAFE_BEGIN(self);
#endif
if (self->weaklist != NULL) {
PyObject_ClearWeakRefs((PyObject *)self);
};
pair_list_dealloc(&self->pairs);
Py_TYPE(self)->tp_free((PyObject *)self);
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_TRASHCAN_END // there should be no code after this
#else
Py_TRASHCAN_SAFE_END(self);
#endif
}

static inline int
Expand Down Expand Up @@ -1236,16 +1228,7 @@ PyDoc_STRVAR(multidict_update_doc,
"Update the dictionary from *other*, overwriting existing keys.");


#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
#define multidict_class_getitem Py_GenericAlias
#else
static inline PyObject *
multidict_class_getitem(PyObject *self, PyObject *arg)
{
Py_INCREF(self);
return self;
}
#endif


PyDoc_STRVAR(sizeof__doc__,
Expand Down Expand Up @@ -1947,9 +1930,7 @@ getversion(PyObject *self, PyObject *md)
static inline void
module_free(void *m)
{
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_CLEAR(multidict_str_lower);
#endif
Py_CLEAR(collections_abc_mapping);
Py_CLEAR(collections_abc_mut_mapping);
Py_CLEAR(collections_abc_mut_multi_mapping);
Expand Down Expand Up @@ -1978,12 +1959,10 @@ static PyModuleDef multidict_module = {
PyMODINIT_FUNC
PyInit__multidict(void)
{
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
multidict_str_lower = PyUnicode_InternFromString("lower");
if (multidict_str_lower == NULL) {
goto fail;
}
#endif

PyObject *module = NULL,
*reg_func_call_result = NULL;
Expand Down Expand Up @@ -2122,9 +2101,7 @@ PyInit__multidict(void)
return module;

fail:
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 9
Py_XDECREF(multidict_str_lower);
#endif
Py_XDECREF(collections_abc_mapping);
Py_XDECREF(collections_abc_mut_mapping);
Py_XDECREF(collections_abc_mut_multi_mapping);
Expand Down
9 changes: 1 addition & 8 deletions multidict/_multidict_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

_marker = object()

if sys.version_info >= (3, 9):
GenericAlias = types.GenericAlias
else:

def GenericAlias(cls):
return cls


class istr(str):
"""Case insensitive str."""
Expand Down Expand Up @@ -140,7 +133,7 @@ def __repr__(self):
body = ", ".join("'{}': {!r}".format(k, v) for k, v in self.items())
return "<{}({})>".format(self.__class__.__name__, body)

__class_getitem__ = classmethod(GenericAlias)
__class_getitem__ = classmethod(types.GenericAlias)


class MultiDictProxy(_Base, MultiMapping):
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ classifiers =

Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13

[options]
python_requires = >= 3.8
python_requires = >= 3.9
install_requires =
typing-extensions >= 4.1.0; python_version < '3.11'
packages =
Expand Down
12 changes: 1 addition & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dataclasses import dataclass
from functools import cached_property
from importlib import import_module
from sys import version_info as _version_info
from types import ModuleType
from typing import Callable, Type

Expand All @@ -14,7 +13,6 @@
from multidict import MultiMapping, MutableMultiMapping

C_EXT_MARK = pytest.mark.c_extension
PY_38_AND_BELOW = _version_info < (3, 9)


@dataclass(frozen=True)
Expand Down Expand Up @@ -163,20 +161,12 @@ def pytest_addoption(

parser.addoption(
"--c-extensions", # disabled with `--no-c-extensions`
action="store_true" if PY_38_AND_BELOW else argparse.BooleanOptionalAction,
action=argparse.BooleanOptionalAction,
default=True,
dest="c_extensions",
help="Test C-extensions (on by default)",
)

if PY_38_AND_BELOW:
parser.addoption(
"--no-c-extensions",
action="store_false",
dest="c_extensions",
help="Skip testing C-extensions (on by default)",
)


def pytest_collection_modifyitems(
session: pytest.Session,
Expand Down
14 changes: 0 additions & 14 deletions tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import types

import pytest
Expand Down Expand Up @@ -85,19 +84,6 @@ def test_create_ci_multidict_proxy_from_multidict(multidict_module):
multidict_module.CIMultiDictProxy(d)


@pytest.mark.skipif(
sys.version_info >= (3, 9), reason="Python 3.9 uses GenericAlias which is different"
)
def test_generic_exists(multidict_module) -> None:
assert multidict_module.MultiDict[int] is multidict_module.MultiDict
assert multidict_module.MultiDictProxy[int] is multidict_module.MultiDictProxy
assert multidict_module.CIMultiDict[int] is multidict_module.CIMultiDict
assert multidict_module.CIMultiDictProxy[int] is multidict_module.CIMultiDictProxy


@pytest.mark.skipif(
sys.version_info < (3, 9), reason="Python 3.9 is required for GenericAlias"
)
def test_generic_alias(multidict_module) -> None:
assert multidict_module.MultiDict[int] == types.GenericAlias(
multidict_module.MultiDict, (int,)
Expand Down
Loading