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

@typing.no_type_check_decorator is nonfunctional #6583

Closed
lunixbochs opened this issue Mar 22, 2019 · 5 comments
Closed

@typing.no_type_check_decorator is nonfunctional #6583

lunixbochs opened this issue Mar 22, 2019 · 5 comments

Comments

@lunixbochs
Copy link

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

@gvanrossum
Copy link
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.

@lunixbochs
Copy link
Author

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

@lunixbochs
Copy link
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.

@ilevkivskyi
Copy link
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.

JukkaL added a commit that referenced this issue Dec 14, 2021
…typeshed` (#6583)

The original PR doesn't apply cleanly so I only included the changes to
builtins to avoid having to manually deal with all the conflicts.
JukkaL added a commit that referenced this issue Dec 14, 2021
* Typeshed cherry-pick: Relax signature of logging.config.loadConfig (#6577)

* Typeshed cherry-pick: Use AbstractSet instead of set in random and inspect (#6574)

* Partial typeshed cherry-pick: Add `SupportsRichComparison` type to `_typeshed` (#6583)

The original PR doesn't apply cleanly so I only included the changes to
builtins to avoid having to manually deal with all the conflicts.
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
* Typeshed cherry-pick: Relax signature of logging.config.loadConfig (python#6577)

* Typeshed cherry-pick: Use AbstractSet instead of set in random and inspect (python#6574)

* Partial typeshed cherry-pick: Add `SupportsRichComparison` type to `_typeshed` (python#6583)

The original PR doesn't apply cleanly so I only included the changes to
builtins to avoid having to manually deal with all the conflicts.
@AlexWaygood
Copy link
Member

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

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants