Skip to content

Commit

Permalink
Drop Python 2.7 (#936)
Browse files Browse the repository at this point in the history
* Drop Python 2.7

The tooling situation around Python 2 has deteriorate to such a degree that
upholding compatibility is not tenable anymore for a volunteer-run project.

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* Add newsfragment

* Run Python 3.5 under coverage to make up for Python 2.7

* Wait for py35 in parallel

* Remove fullmatch kludge

* Remove Python 2-specific code

* Revert empty slot test

Also disable pyupgrade on that file.

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* We DO run under 3.5

* Remove __qualname__ workarounds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update changelog.d/936.breaking.rst

Co-authored-by: Tin Tvrtković <tinchester@gmail.com>

* Compare methods using is

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tin Tvrtković <tinchester@gmail.com>
  • Loading branch information
3 people committed Mar 21, 2022
1 parent d0c73d8 commit 980c8b0
Show file tree
Hide file tree
Showing 44 changed files with 453 additions and 880 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Expand Up @@ -71,7 +71,7 @@ The official tag is `python-attrs` and helping out in support frees us up to imp

- To run the test suite, all you need is a recent [*tox*].
It will ensure the test suite runs with all dependencies against all Python versions just as it will in our [CI].
If you lack some Python versions, you can can always limit the environments like `tox -e py27,py38`, or make it a non-failure using `tox --skip-missing-interpreters`.
If you lack some Python versions, you can can always limit the environments like `tox -e py38,py39`, or make it a non-failure using `tox --skip-missing-interpreters`.

In that case you should look into [*asdf*](https://asdf-vm.com) or [*pyenv*](https://github.com/pyenv/pyenv), which make it very easy to install many different Python versions in parallel.
- Write [good test docstrings](https://jml.io/pages/test-docstrings.html).
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "pypy-2.7", "pypy-3.7", "pypy-3.8"]
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7", "pypy-3.8"]

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -8,12 +8,20 @@ repos:
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args: [--py3-plus, --keep-percent-format]
exclude: "tests/test_slots.py"

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
files: \.py$
language_version: python3.10 # needed for match

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Expand Up @@ -117,7 +117,8 @@ Project Information
its documentation lives at `Read the Docs <https://www.attrs.org/>`_,
the code on `GitHub <https://github.com/python-attrs/attrs>`_,
and the latest release on `PyPI <https://pypi.org/project/attrs/>`_.
It’s rigorously tested on Python 2.7, 3.5+, and PyPy.
It’s rigorously tested on Python 3.5+ and PyPy.
The last version with Python 2.7 support is `21.4.0 <https://pypi.org/project/attrs/21.4.0/>`_.

We collect information on **third-party extensions** in our `wiki <https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs>`_.
Feel free to browse and add your own!
Expand Down
6 changes: 6 additions & 0 deletions changelog.d/936.breaking.rst
@@ -0,0 +1,6 @@
Python 2.7 is not supported anymore.

Dealing with Python 2.7 tooling has become too difficult for a volunteer-run project.

We have supported Python 2 more than 2 years after it was officially discontinued and feel that we have paid our dues.
All version up to 21.4.0 from December 2021 remain fully functional, of course.
1 change: 0 additions & 1 deletion conftest.py
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function

from hypothesis import HealthCheck, settings

Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Expand Up @@ -89,7 +89,6 @@ Full Table of Contents
:maxdepth: 1

license
python-2
changelog


Expand Down
25 changes: 0 additions & 25 deletions docs/python-2.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/why.rst
Expand Up @@ -20,7 +20,7 @@ Whether they're relevant to *you* depends on your circumstances:
There is a long list of features that were sacrificed for the sake of simplicity and while the most obvious ones are validators, converters, :ref:`equality customization <custom-comparison>`, or :doc:`extensibility <extending>` in general, it permeates throughout all APIs.

On the other hand, Data Classes currently do not offer any significant feature that ``attrs`` doesn't already have.
- ``attrs`` supports all mainstream Python versions, including CPython 2.7 and PyPy.
- ``attrs`` supports all mainstream Python versions including PyPy.
- ``attrs`` doesn't force type annotations on you if you don't like them.
- But since it **also** supports typing, it's the best way to embrace type hints *gradually*, too.
- While Data Classes are implementing features from ``attrs`` every now and then, their presence is dependent on the Python version, not the package version.
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Expand Up @@ -32,8 +32,6 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
Expand All @@ -56,7 +54,6 @@
"hypothesis",
"pympler",
"pytest>=4.3.0", # 4.3.0 dropped last use of `convert`
"six",
],
}
if (
Expand Down Expand Up @@ -143,7 +140,7 @@ def find_meta(meta):
long_description_content_type="text/x-rst",
packages=PACKAGES,
package_dir={"": "src"},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
python_requires=">=3.5",
zip_safe=False,
classifiers=CLASSIFIERS,
install_requires=INSTALL_REQUIRES,
Expand Down
1 change: 0 additions & 1 deletion src/attr/__init__.py
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function

import sys

Expand Down
1 change: 0 additions & 1 deletion src/attr/_cmp.py
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function

import functools

Expand Down

0 comments on commit 980c8b0

Please sign in to comment.