Bug 1900684 - python-inject fails to build with Python 3.10: NameError: name 'AnotherClass' is not defined
Summary: python-inject fails to build with Python 3.10: NameError: name 'AnotherClass'...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: python-inject
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Artur Frenszek-Iwicki
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2020-11-23 14:21 UTC by Tomáš Hrnčiar
Modified: 2021-02-09 16:23 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2020-11-23 14:21:33 UTC
python-inject fails to build with Python 3.10.0a2.

=================================== FAILURES ===================================
_______ TestFunctional.test_class_support_in_autoparams_programmaticaly ________

self = <test.test_functional.TestFunctional testMethod=test_class_support_in_autoparams_programmaticaly>

    def test_class_support_in_autoparams_programmaticaly(self):
        class AnotherClass:
            pass
    
        class SomeClass:
            def __init__(self, another_object: AnotherClass):
                self.another_object = another_object
    
        def config(binder):
            binder.bind_to_constructor(SomeClass, autoparams()(SomeClass))
            binder.bind_to_constructor(AnotherClass, autoparams()(AnotherClass))
    
>       inject.configure(config)

test/test_functional.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
inject/__init__.py:356: in configure
    _INJECTOR = Injector(config, bind_in_runtime=bind_in_runtime)
inject/__init__.py:202: in __init__
    config(binder)
test/test_functional.py:71: in config
    binder.bind_to_constructor(SomeClass, autoparams()(SomeClass))
inject/__init__.py:451: in autoparams_decorator
    types = get_type_hints(fn.__init__)
/usr/lib64/python3.10/typing.py:1438: in get_type_hints
    value = _eval_type(value, globalns, localns)
/usr/lib64/python3.10/typing.py:258: in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
/usr/lib64/python3.10/typing.py:519: in _evaluate
    eval(self.__forward_code__, globalns, localns),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   NameError: name 'AnotherClass' is not defined

<string>:1: NameError
=========================== short test summary info ============================
FAILED test/test_functional.py::TestFunctional::test_class_support_in_autoparams_programmaticaly
========================= 1 failed, 47 passed in 0.40s =========================
error: Bad exit status from /var/tmp/rpm-tmp.9hGmAu (%check)

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

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

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 Ben Cotton 2021-02-09 15:27:24 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.


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