Bug 2356179 - monkeytype fails to build with Python 3.14: typing.Union changed with Python 3.14.0a6
Summary: monkeytype fails to build with Python 3.14: typing.Union changed with Python ...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: monkeytype
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2025-03-31 10:01 UTC by Karolina Surma
Modified: 2025-03-31 10:01 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2025-03-31 10:01:43 UTC
monkeytype fails to build with Python 3.14.0a6.

_______________ TestTypeConversion.test_type_round_trip[Union0] ________________
tests/test_encoding.py:82: in test_type_round_trip
    assert type_from_dict(type_to_dict(typ)) == typ
E   AssertionError: assert <class 'typing.Union'> == str | None
E    +  where <class 'typing.Union'> = type_from_dict({'module': 'typing', 'qualname': 'Union'})
E    +    where {'module': 'typing', 'qualname': 'Union'} = type_to_dict(str | None)
_______________ TestTypeConversion.test_type_round_trip[Union1] ________________
tests/test_encoding.py:82: in test_type_round_trip
    assert type_from_dict(type_to_dict(typ)) == typ
E   AssertionError: assert <class 'typing.Union'> == tests.util.Outer.Inner | str | None
E    +  where <class 'typing.Union'> = type_from_dict({'module': 'typing', 'qualname': 'Union'})
E    +    where {'module': 'typing', 'qualname': 'Union'} = type_to_dict(tests.util.Outer.Inner | str | None)
________________ TestTypeConversion.test_type_round_trip[Dict3] ________________
tests/test_encoding.py:82: in test_type_round_trip
    assert type_from_dict(type_to_dict(typ)) == typ
E   assert typing.Dict[str, typing.Union] == typing.Dict[str, str | int]
E     
E     Full diff:
E     - typing.Dict[str, str | int]
E     + typing.Dict[str, typing.Union]
________________ TestTypeConversion.test_type_round_trip[List2] ________________
tests/test_encoding.py:82: in test_type_round_trip
    assert type_from_dict(type_to_dict(typ)) == typ
E   assert typing.List[typing.Union] == typing.List[str | None]
E     
E     Full diff:
E     - typing.List[str | None]
E     + typing.List[typing.Union]
________________ TestTypeConversion.test_type_round_trip[Dict4] ________________
tests/test_encoding.py:82: in test_type_round_trip
    assert type_from_dict(type_to_dict(typ)) == typ
E   assert typing.Dict[str, typing.Union] == typing.Dict[s...Inner] | None]
E     
E     Full diff:
E     - typing.Dict[str, typing.Dict[str, int] | typing.Set[tests.util.Outer.Inner] | None]
E     + typing.Dict[str, typing.Union]
_______ TestRenderAnnotation.test_render_annotation[Union-Optional[int]] _______
tests/test_stubs.py:213: in test_render_annotation
    assert render_annotation(annotation) == expected
E   assert "<class 'Union'>[int, None]" == 'Optional[int]'
E     
E     - Optional[int]
E     + <class 'Union'>[int, None]
____ TestRenderAnnotation.test_render_annotation[List-List[Optional[int]]] _____
tests/test_stubs.py:213: in test_render_annotation
    assert render_annotation(annotation) == expected
E   assert "List[<class ...>[int, None]]" == 'List[Optional[int]]'
E     
E     - List[Optional[int]]
E     + List[<class 'Union'>[int, None]]
_____________ TestFunctionStub.test_optional_parameter_annotation ______________
tests/test_stubs.py:279: in test_optional_parameter_annotation
    assert stub.render() == expected
E   AssertionError: assert 'def test(x: ... -> None: ...' == 'def test(x: ... -> None: ...'
E     
E     - def test(x: Optional[int] = ...) -> None: ...
E     ?             ^^^   ^^
E     + def test(x: <class 'Union'>[int, None] = ...) -> None: ...
E     ?             ^^^^^^^^^^   ^^    ++++++
__________ TestFunctionStub.test_optional_union_parameter_annotation ___________
tests/test_stubs.py:285: in test_optional_union_parameter_annotation
    assert stub.render() == expected
E   AssertionError: assert 'def test(x: ... -> None: ...' == 'def test(x: ... -> None: ...'
E     
E     - def test(x: Optional[Union[int, float]]) -> None: ...
E     ?             ^^^^^^ ^^                ^
E     + def test(x: <class 'Union'>[int, float, None]) -> None: ...
E     ?             ^^^ ^^^^     ++           ^^^^^^
_______________ TestFunctionStub.test_optional_return_annotation _______________
tests/test_stubs.py:291: in test_optional_return_annotation
    assert stub.render() == expected
E   AssertionError: assert 'def test() -...t, None]: ...' == 'def test() -...nal[int]: ...'
E     
E     - def test() -> Optional[int]: ...
E     + def test() -> <class 'Union'>[int, None]: ...
_________ TestFunctionStub.test_split_parameters_across_multiple_lines _________
tests/test_stubs.py:303: in test_split_parameters_across_multiple_lines
    assert stub.render() == expected
E   AssertionError: assert 'def has_leng...t, None]: ...' == 'def has_leng...l[float]: ...'
E     
E       def has_length_exceeds_120_chars(
E           very_long_name_parameter_1: float,
E           very_long_name_parameter_2: float
E     - ) -> Optional[float]: ...
E     + ) -> <class 'Union'>[float, None]: ...
___________ TestFunctionStub.test_default_none_parameter_annotation ____________
tests/test_stubs.py:315: in test_default_none_parameter_annotation
    assert stub.render() == expected
E   AssertionError: assert 'def test(x: ... -> None: ...' == 'def test(x: ... -> None: ...'
E     
E     - def test(x: Optional[int] = ...) -> None: ...
E     ?             ^^^   ^^
E     + def test(x: <class 'Union'>[int, None] = ...) -> None: ...
E     ?             ^^^^^^^^^^   ^^    ++++++
_________________ TestFunctionStub.test_forward_ref_annotation _________________
tests/test_stubs.py:335: in test_forward_ref_annotation
    assert stub.render() == expected
E   assert "def has_forw...', None]: ..." == "def has_forw...onStub']: ..."
E     
E     - def has_forward_ref() -> Optional['TestFunctionStub']: ...
E     ?                          ^^^   ^^
E     + def has_forward_ref() -> <class 'Union'>['TestFunctionStub', None]: ...
E     ?                          ^^^^^^^^^^   ^^                   ++++++
__________________________ TestClassStub.test_render ___________________________
tests/test_stubs.py:369: in test_render
    assert class_stub.render() == expected
E   AssertionError: assert 'class Test:\...e, None]: ...' == 'class Test:\...l[frame]: ...'
E     
E       class Test:
E           bar: str
E           foo: int
E           @classmethod
E     -     def a_class_method(cls, foo: Any) -> Optional[frame]: ...
E     ?                                          ^^^   ^^...
E     
E     ...Full output truncated (6 lines hidden), use '-vv' to show
__________________________ TestModuleStub.test_render __________________________
tests/test_stubs.py:608: in test_render
    assert mod_stub.render() == expected
E   AssertionError: assert 'class DummyA...e, None]: ...' == 'class DummyA...l[frame]: ...'
E     
E       class DummyAnInstanceMethodTypedDict__RENAME_ME__(TypedDict):
E           c: int
E       
E       
E       class FooTypedDict__RENAME_ME__(TypedDict):
E           a: int...
E     
E     ...Full output truncated (46 lines hidden), use '-vv' to show
_________________ TestBuildModuleStubs.test_build_module_stubs _________________
tests/test_stubs.py:807: in test_build_module_stubs
    assert build_module_stubs(entries) == expected
E   AssertionError: assert {'tests.test_...Any'}})), ())} == {'tests.test_...onal'}}), ())}
E     
E     Omitting 1 identical items, use -vv to show
E     Differing items:
E     {'tests.util': ModuleStub((), (ClassStub('Dummy', (FunctionStub('a_static_method', <Signature (foo: Any) -> frame | No...tionKind.INSTANCE: 2>, ['typing'], False)), ()),), ImportBlockStub(ImportMap(<class 'set'>, {'typing': {'Any'}})), ())} != {'tests.util': ModuleStub((), (ClassStub('Dummy', (FunctionStub('a_class_method', <Signature (cls, foo: Any) -> frame ...e | None>, <FunctionKind.STATIC: 3>, ['typing'], False)), ()),), ImportBlockStub({'typing': {'Any', 'Optional'}}), ())}
E     
E     Full diff:
E       {...
E     
E     ...Full output truncated (4 lines hidden), use '-vv' to show
_____ TestGetImportsForAnnotation.test_special_case_types[Union-expected1] _____
tests/test_stubs.py:1233: in test_special_case_types
    assert get_imports_for_annotation(anno) == expected
E   AssertionError: assert ImportMap(<class 'set'>, {}) == {'typing': {'Union'}}
E     
E     Right contains 1 more item:
E     {'typing': {'Union'}}
E     
E     Full diff:
E     + ImportMap(<class 'set'>, {})
E     - {...
E     
E     ...Full output truncated (4 lines hidden), use '-vv' to show
______ TestGetImportsForAnnotation.test_container_types[Union-expected5] _______
tests/test_stubs.py:1254: in test_container_types
    assert get_imports_for_annotation(anno) == expected
E   AssertionError: assert ImportMap(<class 'set'>, {}) == {'tests.util'...g': {'Union'}}
E     
E     Right contains 2 more items:
E     {'tests.util': {'Dummy'}, 'typing': {'Union'}}
E     
E     Full diff:
E     + ImportMap(<class 'set'>, {})
E     - {...
E     
E     ...Full output truncated (7 lines hidden), use '-vv' to show


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/fedora-rawhide-x86_64/08837246-monkeytype/

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

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/

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.


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