Skip to content

Commit ca52a05

Browse files
authored
Merge pull request #231 from pytest-dev/update
Misc updates * Using poetry version 2.0 * Drop support for python 3.8 * Add pre-commit hooks
2 parents 7d6dc57 + 08aca4c commit ca52a05

File tree

10 files changed

+349
-251
lines changed

10 files changed

+349
-251
lines changed

.envrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# config file for `direnv`: https://direnv.net
2+
# load the poetry virtual environment when entering the project directory
3+
4+
strict_env
5+
6+
if [[ ! -f "pyproject.toml" ]]; then
7+
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
8+
exit 2
9+
fi
10+
11+
local VENV="$(poetry env info --path)"
12+
if [[ -z $VENV || ! -d $VENV/bin ]]; then
13+
log_error 'No poetry virtual environment found. Use `poetry install` to create one first.'
14+
exit 2
15+
fi
16+
17+
source_env "$VENV/bin/activate"

.github/workflows/main.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ jobs:
1111
strategy:
1212
matrix:
1313
include:
14-
- python-version: "3.8"
15-
toxfactor: py3.8
16-
ignore-typecheck-outcome: true
17-
ignore-test-outcome: false
1814
- python-version: "3.9"
1915
toxfactor: py3.9
2016
ignore-typecheck-outcome: true
@@ -31,7 +27,7 @@ jobs:
3127
toxfactor: py3.12
3228
ignore-typecheck-outcome: true
3329
ignore-test-outcome: false
34-
- python-version: "3.13-dev"
30+
- python-version: "3.13"
3531
toxfactor: py3.13
3632
ignore-typecheck-outcome: true
3733
ignore-test-outcome: false
@@ -47,7 +43,7 @@ jobs:
4743

4844
- name: Install poetry
4945
run: |
50-
python -m pip install poetry==1.8.3
46+
python -m pip install poetry==2.0.0
5147
5248
- name: Configure poetry
5349
run: |

.pre-commit-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/psf/black
5-
rev: 24.10.0
5+
rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
66
hooks:
77
- id: black
88
- repo: https://github.com/pycqa/isort
9-
rev: 5.13.2
9+
rev: c235f5e450b4b84e58d114ed4c589cbf454175a3 # frozen: 5.13.2
1010
hooks:
1111
- id: isort
1212
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v5.0.0
13+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
1414
hooks:
1515
- id: trailing-whitespace
1616
- id: end-of-file-fixer
1717
- id: check-yaml
1818
- id: check-added-large-files
1919
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.19.0
20+
rev: ce40a160603ab0e7d9c627ae33d7ef3906e2d2b2 # frozen: v3.19.1
2121
hooks:
2222
- id: pyupgrade
23-
args: [--py38-plus]
23+
args: [--py39-plus]
24+
- repo: https://github.com/python-poetry/poetry
25+
rev: "f03d8f98781934df7910be5b6c14756e047ef432" # frozen: 2.0.0
26+
hooks:
27+
- id: poetry-check
28+
args: ["--lock"]

CHANGES.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
Changelog
22
=========
33

4+
All notable changes to this project will be documented in this file.
5+
6+
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.1.0/>`_,
7+
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
8+
49
Unreleased
510
----------
6-
- Declare compatibility with python 3.13
7-
- Drop support for pytest < 7.0.0.
11+
12+
Added
13+
+++++
14+
* Declare compatibility with python 3.13. Supported versions are now: 3.9, 3.10, 3.11, 3.12, 3.13.
15+
16+
Changed
17+
+++++++
18+
* Changelog format updated to follow `Keep a Changelog <https://keepachangelog.com/en/1.1.0/>`_.
19+
20+
Deprecated
21+
++++++++++
22+
23+
Removed
24+
+++++++
25+
* Drop support for python 3.8. Supported versions are now: 3.9, 3.10, 3.11, 3.12, 3.13.
26+
* Drop support for pytest < 7.0.0.
27+
28+
Fixed
29+
+++++
30+
31+
Security
32+
++++++++
833

934
2.7.0
1035
----------

poetry.lock

Lines changed: 261 additions & 186 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
[tool.poetry]
1+
[project]
22
name = "pytest-factoryboy"
33
version = "2.7.0"
44
description = "Factory Boy support for pytest."
5-
authors = ["Oleg Pidsadnyi <[email protected]>"]
6-
maintainers = ["Alessio Bogon <[email protected]>"]
5+
authors = [ { name = "Oleg Pidsadnyi", email= "[email protected]" } ]
6+
maintainers = [ { name = "Alessio Bogon", email = "[email protected]" } ]
77
license = "MIT"
88
readme = "README.rst"
9-
homepage = "https://pytest-factoryboy.readthedocs.io/"
10-
documentation = "https://pytest-factoryboy.readthedocs.io/"
11-
repository = "https://github.com/pytest-dev/pytest-factoryboy"
9+
1210
classifiers = [
1311
"Development Status :: 6 - Mature",
1412
"Intended Audience :: Developers",
@@ -20,37 +18,41 @@ classifiers = [
2018
"Topic :: Software Development :: Libraries",
2119
"Topic :: Utilities",
2220
"Programming Language :: Python :: 3",
23-
"Programming Language :: Python :: 3.8",
2421
"Programming Language :: Python :: 3.9",
2522
"Programming Language :: Python :: 3.10",
2623
"Programming Language :: Python :: 3.11",
2724
"Programming Language :: Python :: 3.12",
2825
"Programming Language :: Python :: 3.13",
2926
]
27+
requires-python = ">=3.9"
28+
dependencies = [
29+
"inflection",
30+
"factory_boy>=2.10.0",
31+
"pytest>=7.0",
32+
"typing_extensions",
33+
"packaging",
34+
]
3035

31-
[tool.poetry.plugins."pytest11"]
32-
"pytest-factoryboy" = "pytest_factoryboy.plugin"
36+
[project.urls]
37+
homepage = "https://pytest-factoryboy.readthedocs.io/"
38+
documentation = "https://pytest-factoryboy.readthedocs.io/"
39+
repository = "https://github.com/pytest-dev/pytest-factoryboy"
3340

34-
[tool.poetry.dependencies]
35-
python = ">=3.8"
36-
inflection = "*"
37-
factory_boy = ">=2.10.0"
38-
pytest = ">=7.0"
39-
typing_extensions = "*"
40-
packaging = "*"
41+
[project.entry-points."pytest11"]
42+
"pytest-factoryboy" = "pytest_factoryboy.plugin"
4143

4244
[tool.poetry.group.dev.dependencies]
4345
mypy = ">=1.4.1"
4446
tox = ">=4.0.8"
4547
coverage = {extras = ["toml"], version = ">=6.5.0"}
4648

4749
[build-system]
48-
requires = ["poetry-core>=1.0.0"]
50+
requires = ["poetry-core (>=2.0.0, <3.0.0)"]
4951
build-backend = "poetry.core.masonry.api"
5052

5153
[tool.black]
5254
line-length = 120
53-
target-version = ["py38", "py39", "py310", "py311", "py312", "py313"]
55+
target-version = ["py39", "py310", "py311", "py312", "py313"]
5456

5557
[tool.isort]
5658
profile = "black"

pytest_factoryboy/compat.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
import pathlib
4-
import sys
53
from collections.abc import Sequence
64
from importlib.metadata import version
75

@@ -11,24 +9,13 @@
119

1210
pytest_version = parse_version(version("pytest"))
1311

14-
__all__ = ("PostGenerationContext", "path_with_stem", "getfixturedefs")
12+
__all__ = ("PostGenerationContext", "getfixturedefs")
1513

1614
try:
1715
from factory.declarations import PostGenerationContext
1816
except ImportError: # factory_boy < 3.2.0
1917
from factory.builder import PostGenerationContext
2018

21-
if sys.version_info >= (3, 9):
22-
23-
def path_with_stem(path: pathlib.Path, stem: str) -> pathlib.Path:
24-
return path.with_stem(stem)
25-
26-
else:
27-
28-
def path_with_stem(path: pathlib.Path, stem: str) -> pathlib.Path:
29-
return path.with_name(stem + path.suffix)
30-
31-
3219
if pytest_version.release >= (8, 1):
3320

3421
def getfixturedefs(fixturemanager: FixtureManager, fixturename: str, node: Node) -> Sequence[FixtureDef] | None:

pytest_factoryboy/fixture.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@
66
import functools
77
import sys
88
import warnings
9+
from collections.abc import Collection, Iterable, Iterator, Mapping
910
from dataclasses import dataclass
1011
from inspect import signature
1112
from types import MethodType
12-
from typing import (
13-
TYPE_CHECKING,
14-
Any,
15-
Callable,
16-
Collection,
17-
Generic,
18-
Iterable,
19-
Iterator,
20-
Mapping,
21-
Type,
22-
TypeVar,
23-
cast,
24-
overload,
25-
)
13+
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar, cast, overload
2614

2715
import factory
2816
import factory.builder
@@ -39,7 +27,7 @@
3927

4028
from .plugin import Request as FactoryboyRequest
4129

42-
FactoryType: TypeAlias = Type[factory.Factory]
30+
FactoryType: TypeAlias = type[factory.Factory]
4331
F = TypeVar("F", bound=FactoryType)
4432
T = TypeVar("T")
4533
T_co = TypeVar("T_co", covariant=True)

pytest_factoryboy/fixturegen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import functools
44
import inspect
5-
from typing import Callable, Collection, TypeVar
5+
from collections.abc import Collection
6+
from typing import Callable, TypeVar
67

78
import pytest
89
from typing_extensions import ParamSpec

tox.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[tox]
22
distshare = {homedir}/.tox/distshare
3-
envlist = py{3.8,3.9,3.10,3.11,3.12,3.13}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,latest,main}
4-
py{3.8,3.9,3.10,3.11}-pytest{7.0,7.1,7.2}
3+
envlist = py{3.9,3.10,3.11,3.12,3.13}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,latest,main}
4+
py{3.9,3.10,3.11}-pytest{7.0,7.1,7.2}
55
mypy
66

7-
87
[testenv]
98
parallel_show_output = true
10-
commands = coverage run -m pytest {posargs:tests}
9+
commands = coverage run -m pytest {posargs}
10+
ignore_outcome =
11+
pytestmain: True
1112
deps =
1213
pytestlatest: pytest
1314
pytestmain: git+https://github.com/pytest-dev/pytest.git@main
@@ -23,6 +24,7 @@ deps =
2324

2425
coverage[toml]
2526

27+
2628
[testenv:mypy]
2729
allowlist_externals = mypy
2830
commands = mypy {posargs:.}

0 commit comments

Comments
 (0)