Skip to content

Commit 8ccbda4

Browse files
authored
Merge pull request #245 from pytest-dev/fix-type-annotations
Fix type annotations
2 parents 8a52ff3 + 560f002 commit 8ccbda4

File tree

7 files changed

+102
-97
lines changed

7 files changed

+102
-97
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ jobs:
4040
ignore-test-outcome: false
4141
- python-version: "3.10"
4242
toxfactor: py3.10
43-
ignore-typecheck-outcome: true
43+
ignore-typecheck-outcome: false
4444
ignore-test-outcome: false
4545
- python-version: "3.11"
4646
toxfactor: py3.11
47-
ignore-typecheck-outcome: true
47+
ignore-typecheck-outcome: false
4848
ignore-test-outcome: false
4949
- python-version: "3.12"
5050
toxfactor: py3.12
51-
ignore-typecheck-outcome: true
51+
ignore-typecheck-outcome: false
5252
ignore-test-outcome: false
5353
- python-version: "3.13"
5454
toxfactor: py3.13
55-
ignore-typecheck-outcome: true
55+
ignore-typecheck-outcome: false
5656
ignore-test-outcome: false
5757
- python-version: "3.14"
5858
toxfactor: py3.14
59-
ignore-typecheck-outcome: true
59+
ignore-typecheck-outcome: false
6060
ignore-test-outcome: false
6161
steps:
6262
- uses: actions/checkout@v4
@@ -71,17 +71,17 @@ jobs:
7171
python -m pip install poetry==2.0.0
7272
- name: Configure poetry
7373
run: |
74-
python -m poetry config virtualenvs.in-project true
74+
poetry config virtualenvs.in-project true
7575
- name: Cache the virtualenv
7676
id: poetry-dependencies-cache
7777
uses: actions/cache@v3
7878
with:
7979
path: ./.venv
80-
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
80+
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}${{ hashFiles('.github/workflows/**') }}
8181
- name: Install dev dependencies
8282
if: steps.poetry-dependencies-cache.outputs.cache-hit != 'true'
8383
run: |
84-
python -m poetry install --only=dev
84+
poetry install
8585
- name: Download artifact
8686
uses: actions/download-artifact@v4
8787
with:
@@ -91,16 +91,15 @@ jobs:
9191
# Ignore errors for older pythons
9292
continue-on-error: ${{ matrix.ignore-typecheck-outcome }}
9393
run: |
94-
source .venv/bin/activate
95-
tox -e mypy
94+
poetry run mypy pytest_factoryboy
9695
- name: Test with tox
9796
continue-on-error: ${{ matrix.ignore-test-outcome }}
9897
run: |
9998
source .venv/bin/activate
10099
coverage erase
101-
# Using `--parallel 4` as it's the number of CPUs in the GitHub Actions runner
102-
# Using `installpkg dist/*.whl` because we want to install the pre-built package (want to test against that)
103-
tox run-parallel -f ${{ matrix.toxfactor }} --parallel 4 --parallel-no-spinner --parallel-live --installpkg dist/*.whl
100+
# Using `--parallel 4` as it's the number of CPUs in the GitHub Actions runner
101+
# Using `installpkg dist/*.whl` because we want to install the pre-built package (want to test against that)
102+
tox run-parallel -f ${{ matrix.toxfactor }} --parallel 4 --parallel-no-spinner --parallel-live --installpkg dist/*.whl
104103
coverage combine
105104
coverage xml
106105
- uses: codecov/codecov-action@v4

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Added
3535
* Declare compatibility with python 3.13. Supported versions are now: 3.9, 3.10, 3.11, 3.12, 3.13.
3636
* Test against pytest 8.4
3737
* Test against python 3.14 (beta)
38+
* Run static type checks.
3839

3940
Changed
4041
+++++++
@@ -51,6 +52,7 @@ Removed
5152
Fixed
5253
+++++
5354
* Fix compatibility with ``pytest 8.4``.
55+
* Fixed internal type annotations.
5456

5557
Security
5658
++++++++

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ check_untyped_defs = true
8888
disallow_untyped_decorators = true
8989
disallow_any_explicit = false
9090
disallow_any_generics = true
91-
disallow_untyped_calls = true
91+
disallow_untyped_calls = false
9292
disallow_untyped_defs = true
9393
ignore_errors = false
9494
ignore_missing_imports = true

pytest_factoryboy/compat.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@
1515
try:
1616
from factory.declarations import PostGenerationContext
1717
except ImportError: # factory_boy < 3.2.0
18-
from factory.builder import PostGenerationContext
18+
from factory.builder import ( # type: ignore[attr-defined, no-redef]
19+
PostGenerationContext,
20+
)
1921

2022
if pytest_version.release >= (8, 1):
2123

22-
def getfixturedefs(fixturemanager: FixtureManager, fixturename: str, node: Node) -> Sequence[FixtureDef] | None:
24+
def getfixturedefs(
25+
fixturemanager: FixtureManager, fixturename: str, node: Node
26+
) -> Sequence[FixtureDef[object]] | None:
2327
return fixturemanager.getfixturedefs(fixturename, node)
2428

2529
else:
2630

27-
def getfixturedefs(fixturemanager: FixtureManager, fixturename: str, node: Node) -> Sequence[FixtureDef] | None:
28-
return fixturemanager.getfixturedefs(fixturename, node.nodeid)
31+
def getfixturedefs(
32+
fixturemanager: FixtureManager, fixturename: str, node: Node
33+
) -> Sequence[FixtureDef[object]] | None:
34+
return fixturemanager.getfixturedefs(fixturename, node.nodeid) # type: ignore[arg-type]
2935

3036

3137
if pytest_version.release >= (8, 4):
@@ -35,4 +41,4 @@ def getfixturedefs(fixturemanager: FixtureManager, fixturename: str, node: Node)
3541
else:
3642
from _pytest.fixtures import FixtureFunction
3743

38-
PytestFixtureT: TypeAlias = FixtureFunction
44+
PytestFixtureT: TypeAlias = FixtureFunction # type: ignore[misc, no-redef]

0 commit comments

Comments
 (0)