# Typing overloaded function signature with non-optional keyword-only argument

**URL:** <https://discuss.python.org/t/typing-overloaded-function-signature-with-non-optional-keyword-only-argument/109489>\
**Category:** Typing\
**Tags:** help\
**Created:** [October 15, 2026, 12:41am UTC](https://discuss.python.org/t/typing-overloaded-function-signature-with-non-optional-keyword-only-argument/109489 "2026-10-15T00:41:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarrotManMatt](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/carrotmanmatt/32/29860_2.png) [@CarrotManMatt](https://discuss.python.org/u/CarrotManMatt)\
**Post date:** [October 15, 2026, 12:41am UTC](https://discuss.python.org/t/typing-overloaded-function-signature-with-non-optional-keyword-only-argument/109489/1 "2026-10-15T00:41:11Z")

</div>

Hiya, mypy has been telling me that the first overloaded function signature here is not covered by the implementation. Am I missing something, as I believe it is. Is this just a current shortcoming of the type-checking that mypy is able to do, or is it my mistake?

```python
from collections.abc import Sequence
from typing import overload

class Foo:
    @overload
    def __init__ (self, *, pragma_type: str) -> None: ...
    @overload
    def __init__ (
        self, raw_rule_codes: Sequence[int], /, pragma_type: str
    ) -> None: ...

    @override
    def __init__ (
        self,
        raw_rule_codes: Sequence[int] = (),
        /,
        pragma_type: str | None = None, # NOTE: Needs a default because comes after another default
    ) -> None:
        if pragma_type is None:
            raise RuntimeError
        ...

```

Surely the `pragma_type` argument being keyword-only in the first overload is handled by the positional-or-keyword-only version in the implementation?

I’ve resorted to unfortunately using a `#type: ignore[misc]` comment on the `@override` line for now.

Any support would be appreciated!

---

<div class="post-metadata">

**Author:** ![mikeshardmind](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mikeshardmind/32/14381_2.png) [@mikeshardmind](https://discuss.python.org/u/mikeshardmind)\
**Post date:** [October 15, 2026, 1:13am UTC](https://discuss.python.org/t/typing-overloaded-function-signature-with-non-optional-keyword-only-argument/109489/2 "2026-10-15T01:13:44Z")

</div>

> [@CarrotManMatt](#):
>
> `def __init__ (self, *, pragma_type: str) -> None: ...`

this overload should be

```python
def __init__ (self, /, *, pragma_type: str) -> None: ...

```

---

<div class="post-metadata">

**Author:** ![CarrotManMatt](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/carrotmanmatt/32/29860_2.png) [@CarrotManMatt](https://discuss.python.org/u/CarrotManMatt)\
**Post date:** [October 15, 2026, 10:55am UTC](https://discuss.python.org/t/typing-overloaded-function-signature-with-non-optional-keyword-only-argument/109489/3 "2026-10-15T10:55:12Z")

</div>

Of course! Thanks, that is what I was missing​💚

---

<div class="post-metadata">

**Author:** ![hauntsaninja](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/hauntsaninja/32/12451_2.png) [@hauntsaninja](https://discuss.python.org/u/hauntsaninja)\
**Post date:** [October 15, 2026, 2:29pm UTC](https://discuss.python.org/t/typing-overloaded-function-signature-with-non-optional-keyword-only-argument/109489/4 "2026-10-15T14:29:29Z")

</div>

I opened a PR to make the mypy diagnostic more helpful: [Improve diagnostic for positional-only related overload error by hauntsaninja · Pull Request #22210 · python/mypy · GitHub](https://github.com/python/mypy/pull/22210)
