Skip to content

TypeError: Exception does not take keyword arguments #2344

Description

@euresti

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions