Skip to content

Commit a080ee5

Browse files
authored
Drop support for EOL Python 3.7 (#118)
2 parents dd25b3b + a071260 commit a080ee5

File tree

7 files changed

+54
-56
lines changed

7 files changed

+54
-56
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["pypy3.8", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
14+
python-version: ["pypy3.8", "3.8", "3.9", "3.10", "3.11", "3.12"]
1515
os: [windows-latest, macos-latest, ubuntu-latest]
1616

1717
steps:

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.3.1
3+
rev: v3.4.0
44
hooks:
55
- id: pyupgrade
6-
args: [--py37-plus]
6+
args: [--py38-plus]
77

88
- repo: https://github.com/psf/black
99
rev: 23.3.0
@@ -16,7 +16,7 @@ repos:
1616
- id: isort
1717

1818
- repo: https://github.com/PyCQA/autoflake
19-
rev: v2.0.2
19+
rev: v2.1.1
2020
hooks:
2121
- id: autoflake
2222
name: autoflake
@@ -61,24 +61,24 @@ repos:
6161
files: "src/"
6262

6363
- repo: https://github.com/pre-commit/mirrors-mypy
64-
rev: v1.1.1
64+
rev: v1.3.0
6565
hooks:
6666
- id: mypy
6767
additional_dependencies: [pytest, types-freezegun, types-setuptools]
6868
args: [--strict]
6969

7070
- repo: https://github.com/tox-dev/pyproject-fmt
71-
rev: 0.9.2
71+
rev: 0.10.0
7272
hooks:
7373
- id: pyproject-fmt
7474

7575
- repo: https://github.com/abravalheri/validate-pyproject
76-
rev: v0.12.2
76+
rev: v0.13
7777
hooks:
7878
- id: validate-pyproject
7979

8080
- repo: https://github.com/tox-dev/tox-ini-fmt
81-
rev: 1.0.0
81+
rev: 1.3.0
8282
hooks:
8383
- id: tox-ini-fmt
8484

.readthedocs.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
python:
2-
pip_install: true
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
# Project page: https://readthedocs.org/projects/python-humanize/
4+
5+
version: 2
6+
7+
mkdocs:
8+
configuration: mkdocs.yml
9+
10+
build:
11+
os: ubuntu-22.04
12+
tools:
13+
python: "3"
14+
15+
commands:
16+
- pip install -U tox
17+
- tox -e docs
18+
- mkdir _readthedocs
19+
- mv site _readthedocs/html

pyproject.toml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,28 @@ keywords = [
1515
license = {text = "MIT"}
1616
maintainers = [{name = "Hugo van Kemenade"}]
1717
authors = [{name = "Jason Moiron", email = "jmoiron@jmoiron.net"}]
18-
requires-python = ">=3.7"
18+
requires-python = ">=3.8"
1919
classifiers = [
20-
"Development Status :: 5 - Production/Stable",
21-
"Intended Audience :: Developers",
22-
"License :: OSI Approved :: MIT License",
23-
"Operating System :: OS Independent",
24-
"Programming Language :: Python",
25-
"Programming Language :: Python :: 3",
26-
"Programming Language :: Python :: 3 :: Only",
27-
"Programming Language :: Python :: 3.7",
28-
"Programming Language :: Python :: 3.8",
29-
"Programming Language :: Python :: 3.9",
30-
"Programming Language :: Python :: 3.10",
31-
"Programming Language :: Python :: 3.11",
32-
"Programming Language :: Python :: 3.12",
33-
"Programming Language :: Python :: Implementation :: CPython",
34-
"Programming Language :: Python :: Implementation :: PyPy",
35-
"Topic :: Text Processing",
36-
"Topic :: Text Processing :: General",
20+
"Development Status :: 5 - Production/Stable",
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: MIT License",
23+
"Operating System :: OS Independent",
24+
"Programming Language :: Python",
25+
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3 :: Only",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Programming Language :: Python :: Implementation :: PyPy",
34+
"Topic :: Text Processing",
35+
"Topic :: Text Processing :: General",
3736
]
3837
dynamic = [
3938
"version",
4039
]
41-
dependencies = [
42-
'importlib-metadata; python_version < "3.8"',
43-
]
4440
[project.optional-dependencies]
4541
tests = [
4642
"freezegun",
@@ -66,9 +62,6 @@ artifacts = [
6662
[tool.hatch.version.raw-options]
6763
local_scheme = "no-local-version"
6864

69-
[tool.black]
70-
target_version = ["py37"]
71-
7265
[tool.isort]
7366
profile = "black"
7467

src/humanize/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Main package for humanize."""
22

3+
import importlib.metadata
4+
35
from humanize.filesize import naturalsize
46
from humanize.i18n import activate, deactivate, decimal_separator, thousands_separator
57
from humanize.number import (
@@ -20,14 +22,7 @@
2022
precisedelta,
2123
)
2224

23-
try:
24-
# Python 3.8+
25-
import importlib.metadata as importlib_metadata
26-
except ImportError:
27-
# <Python 3.7 and lower
28-
import importlib_metadata # type: ignore
29-
30-
__version__ = importlib_metadata.version(__name__)
25+
__version__ = importlib.metadata.version(__name__)
3126

3227

3328
__all__ = [

src/humanize/i18n.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,7 @@ def _pgettext(msgctxt: str, message: str) -> str:
106106
Returns:
107107
str: Translated text.
108108
"""
109-
# This GNU gettext function was added in Python 3.8, so for older versions we
110-
# reimplement it. It works by joining `msgctx` and `message` by '4' byte.
111-
try:
112-
# Python 3.8+
113-
return get_translation().pgettext(msgctxt, message)
114-
except AttributeError:
115-
# Python 3.7 and older
116-
key = msgctxt + "\x04" + message
117-
translation = get_translation().gettext(key)
118-
return message if translation == key else translation
109+
return get_translation().pgettext(msgctxt, message)
119110

120111

121112
def _ngettext(message: str, plural: str, num: int) -> str:

tox.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
[tox]
2-
envlist =
2+
requires =
3+
tox>=4.2
4+
env_list =
35
docs
46
lint
5-
py{py3, 312, 311, 310, 39, 38, 37}
7+
py{py3, 312, 311, 310, 39, 38}
68

79
[testenv]
810
extras =
911
tests
10-
passenv =
12+
pass_env =
1113
FORCE_COLOR
1214
commands =
1315
{envpython} -m pytest --cov humanize --cov tests --cov-report xml {posargs}
@@ -22,7 +24,7 @@ commands =
2224
skip_install = true
2325
deps =
2426
pre-commit
25-
passenv =
27+
pass_env =
2628
PRE_COMMIT_COLOR
2729
commands =
2830
pre-commit run --all-files --show-diff-on-failure

0 commit comments

Comments
 (0)