Skip to content

Expose types.GenericAlias.__getitem__#3499

Merged
youknowone merged 2 commits into
RustPython:mainfrom
moreal:bugfix/genericalias-getitem-method
Jan 22, 2022
Merged

Expose types.GenericAlias.__getitem__#3499
youknowone merged 2 commits into
RustPython:mainfrom
moreal:bugfix/genericalias-getitem-method

Conversation

@moreal
Copy link
Copy Markdown
Contributor

@moreal moreal commented Dec 11, 2021

Description

While making #3497 work, I found types.GenericAlias.__getitem__ wasn't exposed. This pull request just makes it

Check

You can run the below lines to test.

import typing
type(list[int]).__getitem__(list[typing.T], ...)  # expect list[...]

Before this pull request, you can see:

>>>>> import typing
>>>>> type(list[int]).__getitem__(list[typing.T], ...)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'GenericAlias' has no attribute '__getitem__'. Did you mean: '__setattr__'?

Copy link
Copy Markdown
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qingshi163 @Snowapril can this be wriiten with mapping protocol?

Copy link
Copy Markdown
Contributor

@Snowapril Snowapril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youknowone ooh yeah, It can. Actually it must be slot-wrapper (wrapper_descriptor) not a bounded method. At current step, as all the other types that implementing mapping protocol have them as bounded method, seems reasonable 😊

@moreal moreal force-pushed the bugfix/genericalias-getitem-method branch from 752a975 to 964304e Compare December 12, 2021 04:10
@youknowone youknowone merged commit 86ffe9a into RustPython:main Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants