Bug 2366201 - python-typeguard fails to build with Python 3.14: AssertionError: assert 'str | int' == 'Union[str, int]' and more
Summary: python-typeguard fails to build with Python 3.14: AssertionError: assert 'str...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-typeguard
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ben Beasley
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2025-05-14 08:51 UTC by Karolina Surma
Modified: 2025-06-04 11:49 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-06-04 11:49:28 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github agronholm typeguard issues 522 0 None open Tests fail on 3.14b1 2025-05-14 11:36:47 UTC

Description Karolina Surma 2025-05-14 08:51:41 UTC
python-typeguard fails to build with Python 3.14.0b1.

test_positive and test_negative fail with TypeError: AugmentedHelpFormatter.__init__() got an unexpected keyword argument 'prefix_chars'. This is an issue with Python 3.14.0b1 and is expected to be fixed in b2.

And then there's a bunch of genuine issues: 

______________________ TestUnion.test_raw_uniontype_fail _______________________
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_checkers.py:903: in test_raw_uniontype_fail
    check_type(str, types.UnionType)
/builddir/build/BUILD/python-typeguard-4.4.2-build/BUILDROOT/usr/lib/python3.14/site-packages/typeguard/_functions.py:107: in check_type
    check_type_internal(value, expected_type, memo)
/builddir/build/BUILD/python-typeguard-4.4.2-build/BUILDROOT/usr/lib/python3.14/site-packages/typeguard/_checkers.py:951: in check_type_internal
    checker(value, origin_type, args, memo)
/builddir/build/BUILD/python-typeguard-4.4.2-build/BUILDROOT/usr/lib/python3.14/site-packages/typeguard/_checkers.py:437: in check_uniontype
    return check_instance(value, types.UnionType, (), memo)
/builddir/build/BUILD/python-typeguard-4.4.2-build/BUILDROOT/usr/lib/python3.14/site-packages/typeguard/_checkers.py:523: in check_instance
    raise TypeCheckError(f"is not an instance of {qualified_name(origin_type)}")
E   typeguard.TypeCheckError: class str is not an instance of Union

During handling of the above exception, another exception occurred:
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_checkers.py:900: in test_raw_uniontype_fail
    with pytest.raises(
E   AssertionError: Regex pattern did not match.
E    Regex: 'class str is not an instance of \\w+\\.UnionType$'
E    Input: 'class str is not an instance of Union'
______________ test_union_transformer[str | int-Union[str, int]] _______________
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int' == 'Union[str, int]'
E     
E     - Union[str, int]
E     + str | int
_______ test_union_transformer[str | int | bytes-Union[str, int, bytes]] _______
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | bytes' == 'Union[str, int, bytes]'
E     
E     - Union[str, int, bytes]
E     + str | int | bytes
_ test_union_transformer[str | Union[int | bytes, set]-Union[str, int, bytes, set]] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | bytes | set' == 'Union[str, int, bytes, set]'
E     
E     - Union[str, int, bytes, set]
E     + str | int | bytes | set
_ test_union_transformer[str | int | Callable[..., bytes]-Union[str, int, Callable[..., bytes]]] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | ...e[..., bytes]' == 'Union[str, i...[..., bytes]]'
E     
E     - Union[str, int, Callable[..., bytes]]
E     ? ------   ^    ^                     -
E     + str | int | Callable[..., bytes]
E     ?    ^^    ^^
_ test_union_transformer[str | int | Callable[[], bytes]-Union[str, int, Callable[[], bytes]]] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | ...le[[], bytes]' == 'Union[str, i...e[[], bytes]]'
E     
E     - Union[str, int, Callable[[], bytes]]
E     ? ------   ^    ^                    -
E     + str | int | Callable[[], bytes]
E     ?    ^^    ^^
_ test_union_transformer[str | int | Callable[[], bytes | set]-Union[str, int, Callable[[], Union[bytes, set]]]] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | ... bytes | set]' == 'Union[str, i...bytes, set]]]'
E     
E     - Union[str, int, Callable[[], Union[bytes, set]]]
E     + str | int | Callable[[], bytes | set]
_ test_union_transformer[str | int | Literal['foo']-Union[str, int, Literal['foo']]] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   assert "str | int | Literal['foo']" == "Union[str, i...teral['foo']]"
E     
E     - Union[str, int, Literal['foo']]
E     ? ------   ^    ^               -
E     + str | int | Literal['foo']
E     ?    ^^    ^^
_ test_union_transformer[str | int | Literal[-1]-Union[str, int, Literal[-1]]0] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | Literal[-1]' == 'Union[str, int, Literal[-1]]'
E     
E     - Union[str, int, Literal[-1]]
E     + str | int | Literal[-1]
_ test_union_transformer[str | int | Literal[-1]-Union[str, int, Literal[-1]]1] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   AssertionError: assert 'str | int | Literal[-1]' == 'Union[str, int, Literal[-1]]'
E     
E     - Union[str, int, Literal[-1]]
E     + str | int | Literal[-1]
_ test_union_transformer[str | int | Literal["It's a string '\\""]-Union[str, int, Literal['It\\'s a string \\'"']]] _
/builddir/build/BUILD/python-typeguard-4.4.2-build/python-typeguard-4.4.2/tests/test_union_transformer.py:44: in test_union_transformer
    assert evaluated_repr == expected
E   assert 'str | int | ...ring \\\'"\']' == 'Union[str, i...ing \\\'"\']]'
E     
E     - Union[str, int, Literal['It\'s a string \'"']]
E     ? ------   ^    ^                              -
E     + str | int | Literal['It\'s a string \'"']
E     ?    ^^    ^^

============= 13 failed, 470 passed, 4 skipped, 9 xfailed in 2.25s =============

https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14-b1/fedora-rawhide-x86_64/09033264-python-typeguard/

For all our attempts to build python-typeguard with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/package/python-typeguard/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Ben Beasley 2025-05-14 11:36:48 UTC
These are a bit more gnarly than I want to try to patch, but upstream is now aware (https://github.com/agronholm/typeguard/issues/522), and based on past experience I expect they will get around to doing the necessary work before this becomes a serious problem for us.

Comment 2 Ben Beasley 2025-06-04 11:49:28 UTC
As noted in https://github.com/agronholm/typeguard/issues/522#issuecomment-2939727278, I updated to a *very recent* snapshot and am now able to build this for Python 3.14. Now building in the f43-python side tag as https://koji.fedoraproject.org/koji/taskinfo?taskID=133543829.


Note You need to log in before you can comment on or make changes to this bug.