Skip to content

@typing.no_type_check_decorator is nonfunctional #6583

Closed as not planned
Closed as not planned

Description

@lunixbochs
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

I think this firstly needs a typeshed stub, but I think it won't work without special case support in mypy as well.

Related: python/typeshed#2884

Activity

  1. gvanrossum commented on Mar 22, 2019

    @gvanrossum
    Member

    Also related: #607. I propose that we should reserve #607 for the issue that @no_type_check doesn't work for classes, and use this (new) issue for the "meta" decorator @no_type_check_decorator.

  2. lunixbochs commented on Nov 26, 2019

    @lunixbochs
    Author

    There's now a typeshed stub: python/typeshed#3460 (comment)

  3. lunixbochs commented on Jan 21, 2020

    @lunixbochs
    Author

    Can someone advise on how to track within mypy that a function acts as no_type_check? The current no_type_check appears to be handled via the hardcoded path in a few places.

  4. ilevkivskyi commented on Jan 22, 2020

    @ilevkivskyi
    Member

    Can someone advise on how to track within mypy that a function acts as no_type_check? The current no_type_check appears to be handled via the hardcoded path in a few places.

    Although in general we don't like adding new flags to "important" nodes, it looks like in this case this is the only way (because the other way I see is keeping a global state, which is even worse). You can add a flag to FuncDef indicating whether this function can act as a no_type_check decorator, then check this flag on looked up node for every decorator that is a RefExpr.

  5. AlexWaygood commented on Jul 13, 2023

    @AlexWaygood
    Member

    no_type_check_decorator has now been deprecated in Python 3.13, with removal scheduled for Python 3.15: python/cpython#106309.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions