Bug 2369422 - python-Mastodon fails to build with Python 3.14: ValueError: Unknown type <something> | None
Summary: python-Mastodon fails to build with Python 3.14: ValueError: Unknown type <so...
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: python-Mastodon
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gwyn Ciesla
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2371786 (view as bug list)
Depends On:
Blocks: PYTHON3.14 F43FTBFS, RAWHIDEFTBFS F43FailsToInstall, RAWHIDEFailsToInstall
TreeView+ depends on / blocked
 
Reported: 2025-05-30 14:51 UTC by Karolina Surma
Modified: 2025-06-11 16:08 UTC (History)
4 users (show)

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


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github halcy Mastodon.py issues 411 0 None open Test failures on Python 3.14.0b2. 2025-05-30 17:19:12 UTC

Description Karolina Surma 2025-05-30 14:51:59 UTC
python-Mastodon fails to build with Python 3.14.0b2.

There is 9 test failures:

________________________ test_entity_instancestatistics ________________________

mastodon_base = <mastodon.Mastodon.Mastodon object at 0x7fec9cfe8640>
mastodon_admin = <mastodon.Mastodon.Mastodon object at 0x7fec9cfe8770>

    @pytest.mark.vcr(
        filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
        filter_post_data_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
        filter_headers=[('Authorization', 'DUMMY')],
        before_record_request=vcr_filter,
        before_record_response=token_scrubber,
        match_on=['method', 'uri'],
        cassette_library_dir='tests/cassettes_entity_tests'
    )
    def test_entity_instancestatistics(mastodon_base, mastodon_admin):
        mastodon = mastodon_base
        result = mastodon.instance_v1().stats
        assert real_issubclass(type(result), InstanceStatistics), str(type(result)) + ' is not a subclass of InstanceStatistics'
>       result = Entity.from_json(result.to_json())

tests/test_entities.py:830: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mastodon/types_base.py:464: in from_json
    full_type = _str_to_type(mastopy_type)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mastopy_type = 'InstanceStatistics | None'

    def _str_to_type(mastopy_type):
        """
        String name to internal type resolver
        """
        # See if we need to parse a sub-type (i.e. [<something>] in the type name
        sub_type = None
        if "[" in mastopy_type and "]" in mastopy_type:
            mastopy_type, sub_type = mastopy_type.split("[")
            sub_type = sub_type[:-1]
            if mastopy_type not in ["PaginatableList", "NonPaginatableList", "typing.Optional", "typing.Union"]:
                raise ValueError(f"Subtype not allowed for type {mastopy_type} and subtype {sub_type}")
        if "[" in mastopy_type or "]" in mastopy_type:
            raise ValueError(f"Invalid type {mastopy_type}")
        if sub_type is not None and ("[" in sub_type or "]" in sub_type):
            raise ValueError(f"Invalid subtype {sub_type}")
    
        # Build the actual type object.
        from mastodon.return_types import ENTITY_NAME_MAP
        full_type = None
        if sub_type is not None:
            sub_type = ENTITY_NAME_MAP.get(sub_type, None)
            full_type = {
                "PaginatableList": PaginatableList[sub_type],
                "NonPaginatableList": NonPaginatableList[sub_type],
                "typing.Optional": Optional[sub_type],
                "typing.Union": Union[sub_type],
            }[mastopy_type]
        else:
            full_type = ENTITY_NAME_MAP.get(mastopy_type, None)
        if full_type is None:
>           raise ValueError(f"Unknown type {mastopy_type}")
E           ValueError: Unknown type InstanceStatistics | None

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/09104514-python-Mastodon/

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

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 Karolina Surma 2025-06-11 16:00:37 UTC
*** Bug 2371786 has been marked as a duplicate of this bug. ***


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