Skip to content

Commit 8c904e7

Browse files
authored
Merge pull request #29 from vmalloc/fix-python3.13
2 parents 5378595 + 02c655d commit 8c904e7

File tree

9 files changed

+78
-59
lines changed

9 files changed

+78
-59
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ["3.7", "3.8", "3.9", "3.10"]
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
17+
env:
18+
UV_PYTHON: ${{ matrix.python-version }}
1719

1820
steps:
19-
- uses: actions/checkout@v3
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v4
22-
with:
23-
python-version: ${{ matrix.python-version }}
21+
- name: Checkout the repository
22+
uses: actions/checkout@main
23+
- name: Install the default version of uv
24+
id: setup-uv
25+
uses: astral-sh/setup-uv@v3
26+
- name: Print the installed version
27+
run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"
28+
- name: Install Python ${{ matrix.python-version }}
29+
run: uv python install ${{ matrix.python-version }}
2430
- name: Install dependencies
2531
run: make env
2632
- name: Test with pytest
2733
run: make test
28-
- name: Publish package
29-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
30-
uses: pypa/gh-action-pypi-publish@release/v1
31-
with:
32-
password: ${{ secrets.PYPI_API_TOKEN }}

Makefile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
default: test
22

33
test: env
4-
.env/bin/pytest -v
5-
6-
env: .env/.up-to-date
7-
8-
.env/.up-to-date: setup.py Makefile
9-
python -m venv .env
10-
.env/bin/pip install -e ".[testing]"
11-
touch $@
4+
uv run --extra testing pytest tests
125

6+
env:
7+
uv venv
8+
uv pip install -e ".[testing]"

forge/__version__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
import pkg_resources
1+
import sys
2+
if sys.version_info < (3, 8):
3+
import pkg_resources
4+
get_distribution = pkg_resources.get_distribution
5+
else:
6+
from importlib.metadata import distribution
7+
get_distribution = distribution
28

3-
__version__ = pkg_resources.get_distribution('pyforge').version
9+
__version__ = get_distribution('pyforge').version

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[build-system]
2+
requires = ["hatchling>=0.25.1", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "pyforge"
7+
description = "Python mocking framework"
8+
readme = "README.rst"
9+
requires-python = ">=3.8"
10+
license = { text = "BSD 3-Clause License" }
11+
12+
classifiers = [
13+
"Programming Language :: Python :: 3.8",
14+
"Programming Language :: Python :: 3.9",
15+
"Programming Language :: Python :: 3.10",
16+
"Programming Language :: Python :: 3.11",
17+
"Programming Language :: Python :: 3.12",
18+
]
19+
dependencies = ["sentinels>=0.0.4"]
20+
dynamic = ["version"]
21+
22+
authors = [{ name = "Rotem Yaari", email = "[email protected]" }]
23+
24+
[project.urls]
25+
"Homepage" = "https://github.com/vmalloc/pyforge"
26+
27+
[project.optional-dependencies]
28+
testing = ["pytest"]
29+
30+
[tool.hatch.version]
31+
source = "vcs"
32+
33+
[tool.hatch.build.targets.wheel]
34+
packages = ["forge"]

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.cfg

Lines changed: 0 additions & 23 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/test__signature_object.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time
2+
import sys
23
from .ut_utils import TestCase
34
from forge.signature import FunctionSignature
45
from forge.exceptions import SignatureException, InvalidKeywordArgument, FunctionCannotBeBound
@@ -126,11 +127,26 @@ def test__copy(self):
126127
self.assertIsNot(f._args, f2._args)
127128

128129
class BinaryFunctionSignatureTest(TestCase):
129-
def test__binary_global_function(self):
130+
def test__binary_global_function_with_no_parameters(self):
130131
sig = FunctionSignature(time.time)
131132
self.assertEqual(sig._args, [])
132-
self.assertTrue(sig.has_variable_args())
133-
self.assertTrue(sig.has_variable_kwargs())
133+
if sys.version_info[:2] < (3, 13):
134+
self.assertTrue(sig.has_variable_args())
135+
self.assertTrue(sig.has_variable_kwargs())
136+
else:
137+
# Starting 3.13, inspect succeed (not raise TypeError) for buildin functions, like `time.time`
138+
self.assertFalse(sig.has_variable_args())
139+
self.assertFalse(sig.has_variable_kwargs())
140+
def test__binary_global_function_with_parameters(self):
141+
sig = FunctionSignature(time.sleep)
142+
if sys.version_info[:2] < (3, 13):
143+
self.assertEqual(sig._args, [])
144+
self.assertTrue(sig.has_variable_args())
145+
self.assertTrue(sig.has_variable_kwargs())
146+
else:
147+
self.assertEqual(len(sig._args), 1)
148+
self.assertFalse(sig.has_variable_args())
149+
self.assertFalse(sig.has_variable_kwargs())
134150
def test__object_method_placeholders(self):
135151
class SomeObject(object):
136152
pass

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py36,py37,py38,py39,py310
2+
envlist = py38,py39,py310,py311,py312,py313
33

44
[testenv]
55
deps=pytest

0 commit comments

Comments
 (0)