Skip to content

Disallow kwargs from genericalias __new__.#3404

Merged
youknowone merged 1 commit into
RustPython:mainfrom
DimitrisJim:genericalias_no_kwargs
Nov 4, 2021
Merged

Disallow kwargs from genericalias __new__.#3404
youknowone merged 1 commit into
RustPython:mainfrom
DimitrisJim:genericalias_no_kwargs

Conversation

@DimitrisJim
Copy link
Copy Markdown
Member

@DimitrisJim DimitrisJim commented Nov 2, 2021

@Snowapril a review would be great if you could.

@youknowone
Copy link
Copy Markdown
Member

it looks original code is still disallowing kwargs. is it changing error message?

@DimitrisJim
Copy link
Copy Markdown
Member Author

@youknowone Oh right, yeah, basically that, bad naming.

@Snowapril
Copy link
Copy Markdown
Contributor

Snowapril commented Nov 3, 2021

Good! Some incompatibility now become correct.

rustpython

>>>>> GenericAlias()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Expected at least 0 arguments (0 given)
>>>>> kwargs = {"origin":int, "arguments":int}
>>>>> GenericAlias(**kwargs)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: GenericAlias() takes no keywords

python

>>> GenericAlias()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: GenericAlias expected 2 arguments, got 0
>>> kwargs = {"origin":int, "arguments":int}
>>> GenericAlias(**kwargs)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: GenericAlias() takes no keyword arguments

Comment thread vm/src/builtins/genericalias.rs Outdated
@DimitrisJim DimitrisJim force-pushed the genericalias_no_kwargs branch from 8107457 to ffd7e8c Compare November 3, 2021 11:35
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.

Totally looks good to me 😊

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.

The message "takes no keyword arguments" is commonly repeated. I wish we have a way to handle this better.

@youknowone youknowone merged commit 2309e59 into RustPython:main Nov 4, 2021
@DimitrisJim DimitrisJim deleted the genericalias_no_kwargs branch November 7, 2021 09:03
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