Skip to content

typing.no_type_check_decorator is not stubbed in typeshed #2884

Closed

Description

@lunixbochs

https://docs.python.org/3/library/typing.html#typing.no_type_check_decorator

I assume this also needs mypy support, as no_type_check is hardcoded there, but including in typeshed feels like a prereq.

from typing import no_type_check, no_type_check_decorator

@no_type_check_decorator
def test(fn):
    return fn

@test
def blah(x: {'x': 1}):
    pass

@no_type_check
def blah2(x: {'x': 1}):
    pass
$ mypy notypecheck.py 
notypecheck.py:1: error: Module 'typing' has no attribute 'no_type_check_decorator'
notypecheck.py:8: error: Invalid type comment or annotation

Activity

  1. JelleZijlstra commented on Mar 22, 2019

    @JelleZijlstra
    Member

    Yes, we should add it to typeshed. You are right though that type checkers like mypy will need to do additional work in order to make this decorator actually work.

  2. lunixbochs commented on Mar 22, 2019

    @lunixbochs
    ContributorAuthor

    Is this just going to be no_type_check_decorator = object() and the type checker is expected to short circuit it internally?

  3. JelleZijlstra commented on Mar 22, 2019

    @JelleZijlstra
    Member

    I'd prefer if we make it closer to its runtime implementation, which I think would be something like:

    _C = TypeVar("_C", bound=Callable[..., Any])
    
    def no_type_check_decorator(decorator: _C) -> _C: ...
    
  4. CraftSpider commented on Sep 18, 2020

    @CraftSpider
    Contributor

    This was added in #3460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions