Skip to content

TypeError: Exception does not take keyword arguments #2344

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

Closed
euresti opened this issue Jul 23, 2018 · 1 comment
Closed

TypeError: Exception does not take keyword arguments #2344

euresti opened this issue Jul 23, 2018 · 1 comment

Comments

@euresti
Copy link
Contributor

euresti commented Jul 23, 2018

I wrote some bad code which mypy didn't catch. It boils down to:

class FooError(Exception):
    pass
raise FooError("Couldn't foo {username}", username="username")

Running the above yields: TypeError: FooError does not take keyword arguments but mypy doesn't complain. Probably because:

class BaseException:
    def __init__(self, *args: object, **kwargs: object) -> None: ...

I'd just make a change but part of me wonders if this was done on purpose.

@JelleZijlstra
Copy link
Member

I think this is just a bad annotation. BaseException doesn't take kwargs in any Python version I tried (2.7, 3.5, 3.6).

euresti added a commit to euresti/typeshed that referenced this issue Jul 27, 2018
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this issue Jan 23, 2019
timon added a commit to timon/xled that referenced this issue Jan 5, 2020
To quote [Jelle Zijlstra](python/typeshed#2344 (comment)),
> BaseException doesn't take kwargs in any Python version I tried (2.7, 3.5, 3.6).
timon added a commit to timon/xled that referenced this issue Jan 14, 2020
To quote [Jelle Zijlstra](python/typeshed#2344 (comment)),
> BaseException doesn't take kwargs in any Python version I tried (2.7, 3.5, 3.6).
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

No branches or pull requests

2 participants