Skip to content

Adding Protocol _Mapping for format_map method - #3877

Closed
djb4ai wants to merge 5 commits into
python:masterfrom
djb4ai:typing-formatMap
Closed

djb4ai wants to merge 5 commits into
python:masterfrom
djb4ai:typing-formatMap

Conversation

@djb4ai

@djb4ai djb4ai commented Mar 22, 2020

Copy link
Copy Markdown
Contributor

closes #3824

Comment thread stdlib/2/__builtin__.pyi
class _SupportsIndex(Protocol):
def __index__(self) -> int: ...

def runtime_checkable(cls: _TC) -> _TC: ...

Copy link
Copy Markdown
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.

@djb4ai djb4ai Mar 23, 2020 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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