Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1949379

Summary: python-sphinx fails to build with Python 3.10: Different type annotation repr
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-sphinxAssignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: aviso, cstratak, dradez, mhroncok, python-sig, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-12 10:32:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1890881    

Description Tomáš Hrnčiar 2021-04-14 07:25:49 UTC
python-sphinx fails to build with Python 3.10.0a7.

=================================== FAILURES ===================================
_______________________________ test_enum_class ________________________________

app = <SphinxTestApp buildername='html'>

    @pytest.mark.sphinx('html', testroot='ext-autodoc')
    def test_enum_class(app):
        options = {"members": None}
        actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
>       assert list(actual) == [
            '',
            '.. py:class:: EnumCls(value)',
            '   :module: target.enums',
            '',
            '   this is enum class',
            '',
            '',
            '   .. py:method:: EnumCls.say_goodbye()',
            '      :module: target.enums',
            '      :classmethod:',
            '',
            '      a classmethod says good-bye to you.',
            '',
            '',
            '   .. py:method:: EnumCls.say_hello()',
            '      :module: target.enums',
            '',
            '      a method says hello to you.',
            '',
            '',
            '   .. py:attribute:: EnumCls.val1',
            '      :module: target.enums',
            '      :value: 12',
            '',
            '      doc for val1',
            '',
            '',
            '   .. py:attribute:: EnumCls.val2',
            '      :module: target.enums',
            '      :value: 23',
            '',
            '      doc for val2',
            '',
            '',
            '   .. py:attribute:: EnumCls.val3',
            '      :module: target.enums',
            '      :value: 34',
            '',
            '      doc for val3',
            '',
        ]
E       AssertionError: assert ['', '.. py:c...ass', '', ...] == ['', '.. py:c...ass', '', ...]
E         At index 1 diff: '.. py:class:: EnumCls(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)' != '.. py:class:: EnumCls(value)'
E         Use -v to get the full diff

There were some changes in repr() in latest alpha of Python 3.10.
https://docs.python.org/3.10/whatsnew/changelog.html#python-3-10-0-alpha-7

bpo-40066: Enum: adjust repr() to show only enum and member name (not value, nor angle brackets) and str() to show only member name. Update and improve documentation to match.

bpo-40066: Enum’s repr() and str() have changed: repr() is now EnumClass.MemberName and str() is MemberName. Additionally, stdlib Enum’s whose contents are available as module attributes, such as RegexFlag.IGNORECASE, have their repr() as module.name, e.g. re.IGNORECASE.
https://bugs.python.org/issue40066

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/02126982-python-sphinx/

For all our attempts to build python-sphinx with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-sphinx/

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.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
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 Miro Hrončok 2021-05-11 08:41:28 UTC
Current failure:

__________________________ test_signature_annotations __________________________

    def test_signature_annotations():
        from .typing_test_data import (Node, f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
                                       f13, f14, f15, f16, f17, f18, f19, f20, f21)
    
        # Class annotations
        sig = inspect.signature(f0)
        assert stringify_signature(sig) == '(x: int, y: numbers.Integral) -> None'
    
        # Generic types with concrete parameters
        sig = inspect.signature(f1)
        assert stringify_signature(sig) == '(x: List[int]) -> List[int]'
    
        # TypeVars and generic types with TypeVars
        sig = inspect.signature(f2)
        assert stringify_signature(sig) == '(x: List[T], y: List[T_co], z: T) -> List[T_contra]'
    
        # Union types
        sig = inspect.signature(f3)
        assert stringify_signature(sig) == '(x: Union[str, numbers.Integral]) -> None'
    
        # Quoted annotations
        sig = inspect.signature(f4)
        assert stringify_signature(sig) == '(x: str, y: str) -> None'
    
        # Keyword-only arguments
        sig = inspect.signature(f5)
        assert stringify_signature(sig) == '(x: int, *, y: str, z: str) -> None'
    
        # Keyword-only arguments with varargs
        sig = inspect.signature(f6)
        assert stringify_signature(sig) == '(x: int, *args, y: str, z: str) -> None'
    
        # Space around '=' for defaults
        sig = inspect.signature(f7)
        assert stringify_signature(sig) == '(x: Optional[int] = None, y: dict = {}) -> None'
    
        # Callable types
        sig = inspect.signature(f8)
        assert stringify_signature(sig) == '(x: Callable[[int, str], int]) -> None'
    
        sig = inspect.signature(f9)
        assert stringify_signature(sig) == '(x: Callable) -> None'
    
        # Tuple types
        sig = inspect.signature(f10)
        assert stringify_signature(sig) == '(x: Tuple[int, str], y: Tuple[int, ...]) -> None'
    
        # Instance annotations
        sig = inspect.signature(f11)
        if sys.version_info < (3, 10):
            assert stringify_signature(sig) == '(x: CustomAnnotation, y: 123) -> None'
        else:
>           assert stringify_signature(sig) == '(x: CustomAnnotation(), y: 123) -> None'
E           AssertionError: assert '(x: CustomAn... 123) -> None' == '(x: CustomAn... 123) -> None'
E             - (x: CustomAnnotation(), y: 123) -> None
E             ?                     --
E             + (x: CustomAnnotation, y: 123) -> None

tests/test_util_inspect.py:183: AssertionError
= 1 failed, 1640 passed, 1 skipped, 29 deselected, 2 warnings in 146.45s (0:02:26) =

A pragmatic solution: https://src.fedoraproject.org/rpms/python-sphinx/pull-request/31