Skip to content

Commit

Permalink
Merge pull request #108 from smarie/feature/102_py313
Browse files Browse the repository at this point in the history
Added python 3.13
  • Loading branch information
smarie authored Jul 12, 2024
2 parents d31a2c5 + 95d83a1 commit d59b842
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 19 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
uses: actions/[email protected]

- name: Install python ${{ matrix.nox_session.python }} for tests
if: ${{ ! contains(fromJson('["3.13"]'), matrix.nox_session.python ) }}
uses: MatteoH2O1999/[email protected] # actions/[email protected]
id: set-py
with:
Expand All @@ -68,6 +69,18 @@ jobs:
allow-build: info
cache-build: true

- name: Install python ${{ matrix.nox_session.python }} for tests (3.13)
if: contains(fromJson('["3.13"]'), matrix.nox_session.python )
uses: actions/setup-python@v5
id: set-py-latest
with:
# Include all versions including pre releases
# See https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#specifying-a-python-version
python-version: ${{ format('~{0}.0-alpha.0', matrix.nox_session.python) }}
architecture: x64
allow-build: info
cache-build: true

- name: Install python 3.12 for nox
uses: actions/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions ci_tools/nox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
nox_logger = logging.getLogger("nox")


PY27, PY35, PY36, PY37, PY38, PY39, PY310, PY311, PY312 = ("2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11",
"3.12")
PY27, PY35, PY36, PY37, PY38, PY39, PY310, PY311, PY312, PY313 = ("2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10",
"3.11", "3.12", "3.13")
DONT_INSTALL = "dont_install"


Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 1.15.4 - Python 3.13 official support

- Python 3.13 is now supported. PR [#108](https://github.com/smarie/python-makefun/pull/108) and PR
[#104](https://github.com/smarie/python-makefun/pull/104) by [mgorny](https://github.com/mgorny)

### 1.15.3 - bugfix

- Fixed `SyntaxError: invalid syntax` happening when the default value of one argument of the created function is a
Expand Down
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# add parent folder to python path so that we can import noxfile_utils.py
# note that you need to "pip install -r noxfile-requiterements.txt" for this file to work.
sys.path.append(str(Path(__file__).parent / "ci_tools"))
from nox_utils import (PY27, PY37, PY36, PY38, PY39, PY310, PY311, PY312, install_reqs, rm_folder, rm_file,
from nox_utils import (PY27, PY37, PY36, PY38, PY39, PY310, PY311, PY312, PY313, install_reqs, rm_folder, rm_file,
DONT_INSTALL) # noqa


Expand Down Expand Up @@ -54,6 +54,7 @@ class Folders:


ENVS = {
PY313: {"coverage": False, "pkg_specs": {"pip": ">19"}},
PY312: {"coverage": False, "pkg_specs": {"pip": ">19"}},
PY311: {"coverage": False, "pkg_specs": {"pip": ">19"}},
PY310: {"coverage": False, "pkg_specs": {"pip": ">19"}},
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ classifiers =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13

[options]
# one day these will be able to come from requirement files, see https://github.com/pypa/setuptools/issues/1951. But will it be better ?
Expand Down
36 changes: 20 additions & 16 deletions tests/test_partial_and_macros.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import pytest
import re
import sys

import makefun
Expand All @@ -11,6 +12,11 @@

PY2 = sys.version_info < (3, )

# Python 3.13 dedents docstrings, earlier versions just strip initial
# whitespace. Use a regexp to get a consistently dedented docstring
# for comparison across Python versions.
DOCSTRING_NORMALIZE_RE = re.compile(r"^ +", re.MULTILINE)


def test_doc():
def foo(x, y):
Expand Down Expand Up @@ -41,15 +47,15 @@ def foo(x, y):

sig_actual_call = ref_sig_str.replace("*, ", "")

assert bar.__doc__ \
assert DOCSTRING_NORMALIZE_RE.sub("", bar.__doc__) \
== """<This function is equivalent to 'foo%s', see original 'foo' doc below.>
a `foo` function
a `foo` function
:param x:
:param y:
:return:
""" % sig_actual_call
:param x:
:param y:
:return:
""" % sig_actual_call


def test_partial():
Expand Down Expand Up @@ -78,16 +84,16 @@ def foo(x, y, a):

sig_actual_call = "(x, y='hello', a)" # if PY2 else "(x, *, y='hello', a)"

assert foo.__doc__.replace("=KW_ONLY_ARG!", "") \
assert DOCSTRING_NORMALIZE_RE.sub("", foo.__doc__.replace("=KW_ONLY_ARG!", "")) \
== """<This function is equivalent to 'foo%s', see original 'foo' doc below.>
a `foo` function
a `foo` function
:param x:
:param y:
:param a:
:return:
""" % sig_actual_call
:param x:
:param y:
:param a:
:return:
""" % sig_actual_call


def test_issue_57():
Expand Down Expand Up @@ -127,9 +133,7 @@ def f(b=0):
assert m() == -1
assert m.i == 1
# the doc remains untouched in create_function as opposed to wraps, this is normal
assert m.__doc__ == """partial(func, *args, **keywords) - new function with partial application
of the given arguments and keywords.
"""
assert m.__doc__ == functools.partial.__doc__


def test_args_order_and_kind():
Expand Down

0 comments on commit d59b842

Please sign in to comment.