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

Adding Protocol _Mapping for format_map method #3877

Closed
wants to merge 5 commits into from

Conversation

djb4ai
Copy link
Contributor

@djb4ai djb4ai commented Mar 22, 2020

closes #3824


class _SupportsIndex(Protocol):
def __index__(self) -> int: ...

def runtime_checkable(cls: _TC) -> _TC: ...
Copy link
Member

Choose a reason for hiding this comment

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

Why are you adding this (and Collections) to builtins? They don't exist in builtins at runtime.

Copy link
Contributor Author

@djb4ai djb4ai Mar 23, 2020

Choose a reason for hiding this comment

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

Thanks for correcting, I wasn't sure about this, the original stubs for Mapping had those if I just use Protocol[_KT, _VT_co] it keeps saying Invariant type variable '_KT' used in protocol where contravariant one is expected.

Copy link
Member

Choose a reason for hiding this comment

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

Well if nothing else they should be imported from typing.

@JelleZijlstra
Copy link
Member

I provided a simpler solution in #4122.

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.

format_map over specified
2 participants