Coder Social home page Coder Social logo

Python 3.13.0b1: test_typing_extensions: `AttributeError: attribute '__default__' of 'typing.TypeVar' objects is not writable` about typing_extensions HOT 3 CLOSED

befeleme avatar befeleme commented on July 28, 2024
Python 3.13.0b1: test_typing_extensions: `AttributeError: attribute '__default__' of 'typing.TypeVar' objects is not writable`

from typing_extensions.

Comments (3)

AlexWaygood avatar AlexWaygood commented on July 28, 2024 1

@AlexWaygood the changes you made didn't look related to the test failure @befeleme pointed out here. Do you know what's going on here?

The test failure @befeleme pointed out was more than a test failure: the test module was failing at import time. The failure was because the __default__ attribute on typing.TypeVar is read-only on py313+: in our implementation of PEP-696, we were creating instances of typing.TypeVar, then trying to monkeypatch __default__ attributes onto the TypeVar instances after creating them. But it's unnecessary to monkeypatch attributes onto instances of TypeVar on Python 3.13+, because the "real" TypeVar implementation has a default parameter for its constructor on Python 3.13+. So I fixed the error in #378 by simply not independently reimplementing TypeVar at all on Python 3.13+; instead, we now just from typing import TypeVar on Python 3.13+.

from typing_extensions.

AlexWaygood avatar AlexWaygood commented on July 28, 2024

#378 fixed all but one test failure. The last remaining one is to do with AsyncContextManager having an optional second parameter on Python 3.13, but not in the backported version that typing_extensions provides.

from typing_extensions.

JelleZijlstra avatar JelleZijlstra commented on July 28, 2024

@AlexWaygood the changes you made didn't look related to the test failure @befeleme pointed out here. Do you know what's going on here?

Also, there's another failure incoming due to changes I made for beta 2:

% ~/py/cpython/python.exe test_typing_extensions.py 
Traceback (most recent call last):
  File "/Users/jelle/py/typing_extensions/src/test_typing_extensions.py", line 42, in <module>
    from _typed_dict_test_helper import Foo, FooGeneric, VeryAnnotated
  File "/Users/jelle/py/typing_extensions/src/_typed_dict_test_helper.py", line 17, in <module>
    class FooGeneric(TypedDict, Generic[T]):
                                ~~~~~~~^^^
  File "/Users/jelle/py/cpython/Lib/typing.py", line 431, in inner
    return func(*args, **kwds)
  File "/Users/jelle/py/cpython/Lib/typing.py", line 1243, in _generic_class_getitem
    return _GenericAlias(cls, args)
  File "/Users/jelle/py/cpython/Lib/typing.py", line 1420, in __init__
    self.__parameters__ = _collect_parameters(
                          ~~~~~~~~~~~~~~~~~~~^
        args,
        ^^^^^
        enforce_default_ordering=enforce_default_ordering,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
TypeError: _collect_parameters() got an unexpected keyword argument 'enforce_default_ordering'

Will work on a fix for that one.

from typing_extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.