Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __init__ definition for AttributeError #8801

Merged
merged 2 commits into from
Sep 28, 2022
Merged

Add __init__ definition for AttributeError #8801

merged 2 commits into from
Sep 28, 2022

Conversation

klaseskilson
Copy link
Contributor

Since Python 3.10, AttributeError supports keyword arguments for name and obj.

Because of this, doing something like this will cause issues with Mypy:

def do_something(something):
    if not something['field']:
        # Mypy gives you `error: Unexpected keyword argument "obj" for "AttributeError" [call-arg]`
        raise AttributeError(obj=something, name='field')
    ...

Seems like this was only due to a missing __init__ definition.


First contribution here. Sorry if I missed a step or made some mistake.

Since Python 3.10, AttributeError supports keyword arguments for name
and obj.
@klaseskilson klaseskilson changed the title Add init for AttributeError Add __init__ definition for AttributeError Sep 28, 2022
@github-actions

This comment has been minimized.

@klaseskilson klaseskilson marked this pull request as ready for review September 28, 2022 10:35
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Looks good! Just one small thing to fix :)

stdlib/builtins.pyi Outdated Show resolved Hide resolved
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you! And welcome to typeshed!

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit 26ea6b8 into python:master Sep 28, 2022
@klaseskilson klaseskilson deleted the add-attribute-error-init branch September 28, 2022 12:23
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.

2 participants