Skip to content
Merged
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
55 changes: 25 additions & 30 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,37 @@ name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"

categories:
- type: "pre-exclude"
when:
label: "changelog: skip"
- title: "Added"
labels:
- "changelog: Added"
- "enhancement"
semver-increment: "minor"
when:
labels:
- "changelog: Added"
- "enhancement"
- title: "Changed"
label: "changelog: Changed"
semver-increment: "minor"
when:
label: "changelog: Changed"
- title: "Deprecated"
label: "changelog: Deprecated"
semver-increment: "minor"
when:
label: "changelog: Deprecated"
- title: "Removed"
label: "changelog: Removed"
semver-increment: "major"
when:
label: "changelog: Removed"
- title: "Fixed"
labels:
- "changelog: Fixed"
- "bug"
semver-increment: "patch"
when:
labels:
- "changelog: Fixed"
- "bug"
- title: "Security"
label: "changelog: Security"

exclude-labels:
- "changelog: skip"
semver-increment: "minor"
when:
label: "changelog: Security"

autolabeler:
- label: "changelog: skip"
Expand All @@ -29,20 +41,3 @@ autolabeler:

template: |
$CHANGES

version-resolver:
major:
labels:
- "changelog: Removed"
minor:
labels:
- "changelog: Added"
- "changelog: Changed"
- "changelog: Deprecated"
- "enhancement"

patch:
labels:
- "changelog: Fixed"
- "bug"
default: minor
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
fail-fast: false
matrix:
python-version:
- "pypy3.12"
- "pypy3.11"
- "3.15t"
- "3.15"
Expand All @@ -23,7 +24,6 @@ jobs:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
os: [windows-latest, macos-latest, ubuntu-latest]

steps:
Expand Down Expand Up @@ -70,9 +70,12 @@ jobs:
name: ${{ matrix.os }} Python ${{ matrix.python-version }}

success:
if: always()
needs: test
runs-on: ubuntu-latest
name: Test successful
steps:
- name: Success
run: echo Test successful
env:
TEST_RESULT: ${{ needs.test.result }}
run: test "$TEST_RESULT" = "success"
128 changes: 3 additions & 125 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,158 +1,36 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
# Logs
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site
node_modules/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# Jetbrains IDEs
# PyCharm
.idea/

# hatch-vcs
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ priorities:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.5
rev: v0.16.10
hooks:
- id: ruff-check
args: [--exit-non-zero-on-fix]
Expand Down Expand Up @@ -47,7 +47,7 @@ repos:
priority: fix-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.38.0
rev: "0.38.2"
hooks:
- id: check-github-workflows
priority: check
Expand All @@ -61,13 +61,13 @@ repos:
priority: check

- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.29.0
rev: v1.30.1
hooks:
- id: zizmor
priority: check

- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.28.2
rev: v2.30.0
hooks:
- id: pyproject-fmt
priority: fix
Expand All @@ -91,7 +91,7 @@ repos:
priority: fix

- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.9.6
rev: v3.9.9
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ license = "MIT"
license-files = [ "LICENCE" ]
maintainers = [ { name = "Hugo van Kemenade" } ]
authors = [ { name = "Jason Moiron", email = "jmoiron@jmoiron.net" } ]
requires-python = ">=3.10"
requires-python = ">=3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Expand Down Expand Up @@ -57,7 +56,7 @@ build.hooks.vcs.version-file = "src/humanize/_version.py"

[tool.ruff]
fix = true
lint.select = [
lint.extend-select = [
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # pycodestyle errors
Expand Down Expand Up @@ -89,11 +88,13 @@ lint.ignore = [
]
lint.per-file-ignores."tests/*" = [
"D",
"DTZ", # naive local datetimes are intentional
]
lint.flake8-import-conventions.aliases.datetime = "dt"
lint.flake8-import-conventions.banned-from = [ "datetime" ]
lint.flake8-pytest-style.parametrize-names-type = "csv"
lint.flake8-tidy-imports.banned-api."typing.TYPE_CHECKING".msg = "Use TYPE_CHECKING = False instead"
lint.flake8-tidy-imports.banned-api."re.match".msg = "use re.fullmatch() or re.search() instead"
lint.flake8-tidy-imports.banned-api."typing.TYPE_CHECKING".msg = "use TYPE_CHECKING = False instead"
lint.isort.known-first-party = [ "humanize" ]
lint.isort.required-imports = [ "from __future__ import annotations" ]
lint.pydocstyle.convention = "google"
Expand All @@ -115,6 +116,8 @@ minversion = "9.0"
testpaths = [ "tests" ]

[tool.coverage]
run.disable_warnings = [ "no-sysmon" ] # 3.11
run.core = "sysmon" # default for 3.14+, available for 3.12+
# Regexes for lines to exclude from consideration
report.exclude_also = [
# Don't complain if non-runnable code isn't run:
Expand Down
8 changes: 4 additions & 4 deletions src/humanize/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __lt__(self, other: Any) -> Any:
def _now() -> dt.datetime:
import datetime as dt

return dt.datetime.now()
return dt.datetime.now() # noqa: DTZ005 # naive local time is intentional


def _abs_timedelta(delta: dt.timedelta) -> dt.timedelta:
Expand Down Expand Up @@ -321,7 +321,7 @@ def _convert_aware_datetime(
import datetime as dt

if isinstance(value, dt.datetime) and value.tzinfo is not None:
value = dt.datetime.fromtimestamp(value.timestamp())
value = dt.datetime.fromtimestamp(value.timestamp()) # noqa: DTZ006
return value


Expand All @@ -341,7 +341,7 @@ def naturalday(value: dt.date | dt.datetime, format: str = "%b %d") -> str:
if isinstance(value, dt.datetime) and value.tzinfo is not None:
today = dt.datetime.now(value.tzinfo).date()
else:
today = dt.date.today()
today = dt.date.today() # noqa: DTZ011
value = dt.date(value.year, value.month, value.day)
except AttributeError:
# Passed value wasn't date-ish
Expand Down Expand Up @@ -372,7 +372,7 @@ def naturaldate(value: dt.date | dt.datetime) -> str:
if isinstance(value, dt.datetime) and value.tzinfo is not None:
today = dt.datetime.now(value.tzinfo).date()
else:
today = dt.date.today()
today = dt.date.today() # noqa: DTZ011
value = dt.date(value.year, value.month, value.day)
except AttributeError:
# Passed value wasn't date-ish
Expand Down
2 changes: 0 additions & 2 deletions tests/test_filesize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""Tests for filesize humanizing."""

from __future__ import annotations
Expand Down
Loading
Loading