| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
I can't review the C code, but I much prefer this behaviour to the behaviour on main! Manual testing also didn't reveal any bugs.
Maybe it's also worth testing that TypeAliasType.__module__ == 'typing'? (I.e., accessing __module__ on the class itself rather than instances of the class.) That's the only comment I have!
Sorry, something went wrong.
|
One nit about tests: may it be useful to define a type alias in another module, and check something like assertEqual(x.Alias.__module__, x) where x is a some module. |
Sorry, something went wrong.
|
@AlexWaygood unfortunately this no longer works, I get test test_type_aliases failed -- Traceback (most recent call last):
File "/Users/jelle/py/cpython/Lib/test/test_type_aliases.py", line 211, in test_module
self.assertEqual(TypeAliasType.__module__, "typing")
AssertionError: <attribute '__module__' of 'typing.TypeAliasType' objects> != 'typing'
This seems to be an inescapable consequence of how heap types work ( Line 1045 in 1b5a2b0 @Eclips4 good call about tests in another module, I'll add some. As for the module being NULL, apparently that can happen in various exotic situations where there is no calling function or that function has no module. Not 100% sure how to reproduce that. |
Sorry, something went wrong.
That's a shame :( This inconsistency is a little unfortunate: >>> from typing import TypeAliasType, TypeVar
>>> TypeAliasType.__module__
<attribute '__module__' of 'typing.TypeAliasType' objects>
>>> TypeVar.__module__
'typing'
>>> type T = int | str
>>> T.__module__
'__main__'
>>> TypeVar("T").__module__
'__main__' |
Sorry, something went wrong.
(But if there's no way of resolving that, then this is still definitely an improvement on the status quo :) |
Sorry, something went wrong.
|
Possible solutions:
|
Sorry, something went wrong.
Yeah, I agree that that allowing arbitrary setting of attributes seems unnecessary |
Sorry, something went wrong.
|
oops, messed up the merge |
Sorry, something went wrong.
There was a problem hiding this comment.
Assuming the refleak buildbots are happy, this LGTM.
Sorry, something went wrong.
* main: pythongh-74690: Don't set special protocol attributes on non-protocol subclasses of protocols (python#104622) pythongh-104623: Update Windows installer to use SQLite 3.42.0 (python#104625) pythongh-104050: Add more type annotations to Argument Clinic (python#104628) pythongh-104629: Don't skip test_clinic if _testclinic is missing (python#104630) pythongh-104549: Set __module__ on TypeAliasType (python#104550) pythongh-104050: Improve some typing around `default`s and sentinel values (python#104626) pythongh-104146: Remove unused vars from Argument Clinic (python#104627) pythongh-104615: don't make unsafe swaps in apply_static_swaps (python#104620) pythonGH-104484: Add case_sensitive argument to `pathlib.PurePath.match()` (pythonGH-104565) pythonGH-96803: Document and test new unstable internal frame API functions (pythonGH-104211) pythonGH-104580: Don't cache eval breaker in interpreter (pythonGH-104581)
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.