Skip to content

Commit

Permalink
Merge branch 'master' into pytest-collect-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm authored Nov 3, 2024
2 parents 4e28713 + 6d6b4de commit 9e15845
Show file tree
Hide file tree
Showing 18 changed files with 969 additions and 525 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", pypy-3.10]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", pypy-3.10]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
Expand All @@ -14,14 +14,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
rev: v0.7.2
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [ "typing_extensions" ]
Expand Down
12 changes: 4 additions & 8 deletions docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,11 @@ Protocol checking
+++++++++++++++++

As of version 4.3.0, Typeguard can check instances and classes against Protocols,
regardless of whether they were annotated with :decorator:`typing.runtime_checkable`.
regardless of whether they were annotated with
:func:`@runtime_checkable <typing.runtime_checkable>`.

There are several limitations on the checks performed, however:

* For non-callable members, only presence is checked for; no type compatibility checks
are performed
* For methods, only the number of positional arguments are checked against, so any added
keyword-only arguments without defaults don't currently trip the checker
* Likewise, argument types are not checked for compatibility
The only current limitation is that argument annotations are not checked for
compatibility, however this should be covered by static type checkers pretty well.

Special considerations for ``if TYPE_CHECKING:``
------------------------------------------------
Expand Down
28 changes: 28 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ Version history
This library adheres to
`Semantic Versioning 2.0 <https://semver.org/#semantic-versioning-200>`_.

**UNRELEASED**

- Dropped Python 3.8 support
- Changed the signature of ``typeguard_ignore()`` to be compatible with
``typing.no_type_check()`` (PR by @jolaf)
- Avoid creating reference cycles when type checking uniontypes and classes
- Fixed checking of variable assignments involving tuple unpacking
(`#486 <https://github.com/agronholm/typeguard/issues/486>`_)
- Fixed ``TypeError`` when checking a class against ``type[Self]``
(`#481 <https://github.com/agronholm/typeguard/issues/481>`_)
- Fixed checking of protocols on the class level (against ``type[SomeProtocol]``)
(`#498 <https://github.com/agronholm/typeguard/issues/498>`_)
- Fixed ``Self`` checks in instance/class methods that have positional-only arguments
- Fixed explicit checks of PEP 604 unions against ``types.UnionType``
(`#467 <https://github.com/agronholm/typeguard/issues/467>`_)
- Fixed checks against annotations wrapped in ``NotRequired`` not being run unless the
``NotRequired`` is a forward reference
(`#454 <https://github.com/agronholm/typeguard/issues/454>`_)

**4.4.0** (2024-10-27)

- Added proper checking for method signatures in protocol checks
(`#465 <https://github.com/agronholm/typeguard/pull/465>`_)
- Fixed basic support for intersection protocols
(`#490 <https://github.com/agronholm/typeguard/pull/490>`_; PR by @antonagestam)
- Fixed protocol checks running against the class of an instance and not the instance
itself (this produced wrong results for non-method member checks)

**4.3.0** (2024-05-27)

- Added support for checking against static protocols
Expand Down
34 changes: 16 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"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",
]
requires-python = ">= 3.8"
requires-python = ">= 3.9"
dependencies = [
"importlib_metadata >= 3.6; python_version < '3.10'",
"typing_extensions >= 4.10.0",
Expand Down Expand Up @@ -80,36 +80,34 @@ src = ["src"]

[tool.ruff.lint]
extend-select = [
"W", # pycodestyle warnings
"B0", # flake8-bugbear
"I", # isort
"PGH", # pygrep-hooks
"UP", # pyupgrade
"B0", # flake8-bugbear
"W", # pycodestyle warnings
]
ignore = [
"S307",
"B008",
"UP006",
"UP035",
]

[tool.mypy]
python_version = "3.9"
python_version = "3.11"
strict = true
pretty = true

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = pypy3, py38, py39, py310, py311, py312, py313
env_list = ["py39", "py310", "py311", "py312", "py313"]
skip_missing_interpreters = true
minversion = 4.0

[testenv]
extras = test
commands = coverage run -m pytest {posargs}
package = editable
[tool.tox.env_run_base]
commands = [["coverage", "run", "-m", "pytest", { replace = "posargs", extend = true }]]
package = "editable"
extras = ["test"]

[testenv:docs]
extras = doc
package = editable
commands = sphinx-build -W -n docs build/sphinx
"""
[tool.tox.env.docs]
depends = []
extras = ["doc"]
commands = [["sphinx-build", "-W", "-n", "docs", "build/sphinx"]]
Loading

0 comments on commit 9e15845

Please sign in to comment.