diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 7a574c9e0..14473867a 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -6,7 +6,7 @@ jobs: python-check: strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] platform: [ubuntu-22.04, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/commitizen/changelog_formats/__init__.py b/commitizen/changelog_formats/__init__.py index 9a5eea7ab..bb09f6fda 100644 --- a/commitizen/changelog_formats/__init__.py +++ b/commitizen/changelog_formats/__init__.py @@ -1,12 +1,8 @@ from __future__ import annotations -import sys -from typing import Callable, ClassVar, Protocol - -if sys.version_info >= (3, 10): - from importlib import metadata -else: - import importlib_metadata as metadata +from collections.abc import Callable +from importlib import metadata +from typing import ClassVar, Protocol from commitizen.changelog import Metadata from commitizen.config.base_config import BaseConfig diff --git a/commitizen/cz/__init__.py b/commitizen/cz/__init__.py index cb17fe32c..5f2c8c0f2 100644 --- a/commitizen/cz/__init__.py +++ b/commitizen/cz/__init__.py @@ -2,14 +2,9 @@ import importlib import pkgutil -import sys import warnings from collections.abc import Iterable - -if sys.version_info >= (3, 10): - from importlib import metadata -else: - import importlib_metadata as metadata +from importlib import metadata from commitizen.cz.base import BaseCommitizen diff --git a/commitizen/cz/base.py b/commitizen/cz/base.py index 8466b58bb..f0e271397 100644 --- a/commitizen/cz/base.py +++ b/commitizen/cz/base.py @@ -1,8 +1,8 @@ from __future__ import annotations from abc import ABCMeta, abstractmethod -from collections.abc import Iterable, Mapping -from typing import Any, Callable, Protocol +from collections.abc import Callable, Iterable, Mapping +from typing import Any, Protocol from jinja2 import BaseLoader, PackageLoader from prompt_toolkit.styles import Style diff --git a/commitizen/providers/__init__.py b/commitizen/providers/__init__.py index 3e01fe22f..d8aba667f 100644 --- a/commitizen/providers/__init__.py +++ b/commitizen/providers/__init__.py @@ -1,13 +1,8 @@ from __future__ import annotations -import sys +from importlib import metadata from typing import cast -if sys.version_info >= (3, 10): - from importlib import metadata -else: - import importlib_metadata as metadata - from commitizen.config.base_config import BaseConfig from commitizen.exceptions import VersionProviderUnknown from commitizen.providers.base_provider import VersionProvider diff --git a/commitizen/question.py b/commitizen/question.py index 393e38609..043b8f3ba 100644 --- a/commitizen/question.py +++ b/commitizen/question.py @@ -1,4 +1,5 @@ -from typing import Callable, Literal, TypedDict, Union +from collections.abc import Callable +from typing import Literal, TypedDict class Choice(TypedDict, total=False): @@ -29,4 +30,4 @@ class ConfirmQuestion(TypedDict): default: bool -CzQuestion = Union[ListQuestion, InputQuestion, ConfirmQuestion] +CzQuestion = ListQuestion | InputQuestion | ConfirmQuestion diff --git a/commitizen/version_schemes.py b/commitizen/version_schemes.py index 0696d85aa..0315096a1 100644 --- a/commitizen/version_schemes.py +++ b/commitizen/version_schemes.py @@ -3,6 +3,7 @@ import re import sys import warnings +from importlib import metadata from itertools import zip_longest from typing import ( TYPE_CHECKING, @@ -14,11 +15,6 @@ runtime_checkable, ) -if sys.version_info >= (3, 10): - from importlib import metadata -else: - import importlib_metadata as metadata - from packaging.version import InvalidVersion # noqa: F401 (expose the common exception) from packaging.version import Version as _BaseVersion @@ -26,11 +22,7 @@ from commitizen.exceptions import VersionSchemeUnknown if TYPE_CHECKING: - # TypeAlias is Python 3.10+ but backported in typing-extensions - if sys.version_info >= (3, 10): - from typing import TypeAlias - else: - from typing_extensions import TypeAlias + from typing import TypeAlias # Self is Python 3.11+ but backported in typing-extensions if sys.version_info < (3, 11): diff --git a/docs/README.md b/docs/README.md index fa3fab223..051962d4f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -55,7 +55,7 @@ This standardization makes your commit history more readable and meaningful, whi Before installing Commitizen, ensure you have: -- [Python](https://www.python.org/downloads/) `3.9+` +- [Python](https://www.python.org/downloads/) `3.10+` - [Git][gitscm] `1.8.5.2+` ### Installation diff --git a/docs/contributing.md b/docs/contributing.md index 16db93062..0d5a7368e 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -15,7 +15,7 @@ If you're a first-time contributor, please check out issues labeled [good first ### Required Tools 1. **Python Environment** - - Python `>=3.9` + - Python `>=3.10` - [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) `>=2.0.0` 2. **Version Control & Security** - Git diff --git a/docs/contributing_tldr.md b/docs/contributing_tldr.md index 9eecc3efa..0ab03ce90 100644 --- a/docs/contributing_tldr.md +++ b/docs/contributing_tldr.md @@ -2,7 +2,7 @@ Feel free to send a PR to update this file if you find anything useful. 🙇 ## Environment -- Python `>=3.9` +- Python `>=3.10` - [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) `>=2.0.0` ## Useful commands @@ -21,8 +21,8 @@ poetry format # Check if ruff and mypy are happy poetry lint -# Check if mypy is happy in python 3.9 -mypy --python-version 3.9 +# Check if mypy is happy in python 3.10 +mypy --python-version 3.10 # Run tests in parallel. pytest -n auto # This may take a while. diff --git a/docs/tutorials/gitlab_ci.md b/docs/tutorials/gitlab_ci.md index 6f6d53a57..0af05c4e7 100644 --- a/docs/tutorials/gitlab_ci.md +++ b/docs/tutorials/gitlab_ci.md @@ -74,7 +74,7 @@ test: auto-bump: stage: auto-bump - image: python:3.9 + image: python:3.10 before_script: - "which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )" - eval `ssh-agent -s` diff --git a/poetry.lock b/poetry.lock index 49df9dcd5..24189bb87 100644 --- a/poetry.lock +++ b/poetry.lock @@ -395,7 +395,7 @@ description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" groups = ["dev", "test"] -markers = "python_version < \"3.11\"" +markers = "python_version == \"3.10\"" files = [ {file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"}, {file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"}, @@ -512,31 +512,6 @@ files = [ [package.extras] all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] -[[package]] -name = "importlib-metadata" -version = "8.6.1" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.9" -groups = ["main", "documentation"] -markers = "python_version == \"3.9\"" -files = [ - {file = "importlib_metadata-8.6.1-py3-none-any.whl", hash = "sha256:02a89390c1e15fdfdc0d7c6b25cb3e62650d0494005c97d6f148bf5b9787525e"}, - {file = "importlib_metadata-8.6.1.tar.gz", hash = "sha256:310b41d755445d74569f993ccfc22838295d9fe005425094fad953d7f15c8580"}, -] - -[package.dependencies] -zipp = ">=3.20" - -[package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\""] -cover = ["pytest-cov"] -doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -enabler = ["pytest-enabler (>=2.2)"] -perf = ["ipython"] -test = ["flufl.flake8", "importlib_resources (>=1.3) ; python_version < \"3.9\"", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-perf (>=0.9.2)"] -type = ["pytest-mypy"] - [[package]] name = "iniconfig" version = "2.1.0" @@ -572,7 +547,6 @@ prompt-toolkit = ">=3.0.41,<3.1.0" pygments = ">=2.4.0" stack-data = "*" traitlets = ">=5" -typing-extensions = {version = "*", markers = "python_version < \"3.10\""} [package.extras] all = ["black", "curio", "docrepr", "exceptiongroup", "ipykernel", "ipyparallel", "ipywidgets", "matplotlib", "matplotlib (!=3.2.0)", "nbconvert", "nbformat", "notebook", "numpy (>=1.22)", "pandas", "pickleshare", "pytest (<7)", "pytest (<7.1)", "pytest-asyncio (<0.22)", "qtconsole", "setuptools (>=18.5)", "sphinx (>=1.3)", "sphinx-rtd-theme", "stack-data", "testpath", "trio", "typing-extensions"] @@ -637,9 +611,6 @@ files = [ {file = "markdown-3.8.2.tar.gz", hash = "sha256:247b9a70dd12e27f67431ce62523e675b866d254f900c4fe75ce3dda62237c45"}, ] -[package.dependencies] -importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} - [package.extras] docs = ["mdx_gh_links (>=0.2)", "mkdocs (>=1.6)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"] testing = ["coverage", "pyyaml"] @@ -795,7 +766,6 @@ files = [ click = ">=7.0" colorama = {version = ">=0.4", markers = "platform_system == \"Windows\""} ghp-import = ">=1.0" -importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} jinja2 = ">=2.11.1" markdown = ">=3.3.6" markupsafe = ">=2.0.1" @@ -824,7 +794,6 @@ files = [ ] [package.dependencies] -importlib-metadata = {version = ">=4.3", markers = "python_version < \"3.10\""} mergedeep = ">=1.3.4" platformdirs = ">=2.2.0" pyyaml = ">=5.1" @@ -1617,7 +1586,7 @@ files = [ {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, ] -markers = {dev = "python_version < \"3.11\"", linters = "python_version < \"3.11\"", test = "python_full_version <= \"3.11.0a6\""} +markers = {dev = "python_version == \"3.10\"", linters = "python_version == \"3.10\"", test = "python_full_version <= \"3.11.0a6\""} [[package]] name = "tomlkit" @@ -1743,7 +1712,7 @@ files = [ {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, ] -markers = {main = "python_version < \"3.11\"", dev = "python_version < \"3.11\"", script = "python_version < \"3.11\"", test = "python_version < \"3.11\""} +markers = {main = "python_version == \"3.10\"", dev = "python_version == \"3.10\"", script = "python_version == \"3.10\"", test = "python_version == \"3.10\""} [[package]] name = "urllib3" @@ -1931,28 +1900,7 @@ files = [ {file = "wrapt-1.17.3.tar.gz", hash = "sha256:f66eb08feaa410fe4eebd17f2a2c8e2e46d3476e9f8c783daa8e09e0faa666d0"}, ] -[[package]] -name = "zipp" -version = "3.23.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.9" -groups = ["main", "documentation"] -markers = "python_version == \"3.9\"" -files = [ - {file = "zipp-3.23.0-py3-none-any.whl", hash = "sha256:071652d6115ed432f5ce1d34c336c0adfd6a884660d1e9712a256d3d3bd4b14e"}, - {file = "zipp-3.23.0.tar.gz", hash = "sha256:a07157588a12518c9d4034df3fbbee09c814741a33ff63c05fa29d26a2404166"}, -] - -[package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\""] -cover = ["pytest-cov"] -doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -enabler = ["pytest-enabler (>=2.2)"] -test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more_itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] -type = ["pytest-mypy"] - [metadata] lock-version = "2.1" -python-versions = ">=3.9,<4.0" -content-hash = "cd5648d8aad7b58913b1c0e4cd4f04c98d5bcfa7e4ef8e7bb994a59492d7d4a2" +python-versions = ">=3.10,<4.0" +content-hash = "ec334c173a75c11d46c123e7722c932b70df15a5b3e3a2210fa04b15a1b62857" diff --git a/pyproject.toml b/pyproject.toml index 8211b969d..dff1d2b8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ maintainers = [ ] license = { file = "LICENSE" } readme = "docs/README.md" -requires-python = ">=3.9,<4.0" +requires-python = ">=3.10,<4.0" dependencies = [ "questionary (>=2.0,<3.0)", # Exclude transitive dependency due to known issue in questionary: https://github.com/tmbo/questionary/issues/454 @@ -38,11 +38,11 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "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", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: Implementation :: CPython", "License :: OSI Approved :: MIT License", ] @@ -174,7 +174,7 @@ testpaths = ["tests/"] [tool.tox] requires = ["tox>=4.22"] -env_list = ["3.9", "3.10", "3.11", "3.12", "3.13"] +env_list = ["3.10", "3.11", "3.12", "3.13", "3.14"] [tool.tox.env_run_base] description = "Run tests suite against Python {base_python}" diff --git a/tests/test_factory.py b/tests/test_factory.py index d81a84b3d..20ce49d78 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -1,11 +1,7 @@ import sys +from importlib import metadata from textwrap import dedent -if sys.version_info >= (3, 10): - from importlib import metadata -else: - import importlib_metadata as metadata - import pytest from commitizen import BaseCommitizen, defaults, factory diff --git a/tests/test_version_schemes.py b/tests/test_version_schemes.py index 8e2dae902..0591c3e1b 100644 --- a/tests/test_version_schemes.py +++ b/tests/test_version_schemes.py @@ -1,11 +1,6 @@ from __future__ import annotations -import sys - -if sys.version_info >= (3, 10): - from importlib import metadata -else: - import importlib_metadata as metadata +from importlib import metadata import pytest from pytest_mock import MockerFixture