[Python-ideas] Proposal: Use mypy syntax for function annotations
Bob Ippolito
bob at redivi.com
Fri Aug 15 02:46:51 CEST 2014
More information about the Python-ideas mailing list
Fri Aug 15 02:46:51 CEST 2014
- Previous message: [Python-ideas] Proposal: Use mypy syntax for function annotations
- Next message: [Python-ideas] Proposal: Use mypy syntax for function annotations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Aug 14, 2014 at 5:14 PM, Steven D'Aprano <steve at pearwood.info> wrote: > On Thu, Aug 14, 2014 at 01:54:20PM -0700, Bob Ippolito wrote: > > * Deprecation of using function annotations for any other purpose. They > > can't really be composed, and ideally type checkers can work primarily at > > the syntax level and not have to evaluate the module with a full Python > > interpreter in order to extract the annotations, so it's best to keep the > > syntax uniform. > > -1 > > I don't think this one is justified. At the very least, I think the > decision to deprecate or not should be deferred until at least 3.7. It's > enough to say that: > > - you can use function annotations for type checking; or > > - you can use function annotations for something else; > > but not both at the same time. I don't think it is a big burden to have > mypy and other linters support an "opt-out" decorator, say, so that > projects can use annotations for something else without confusing the > linter. > Certainly using annotations for purposes other than type checking would be permissible, but discouraged. No enforcement of any kind is proposed, just language to go in the documentation. It would be non-trivial for the Python compiler or runtime to enforce it anyway! For that sort of annotation, a decorator probably isn't best, some module-level syntax would likely be more appropriate. > As I understand it, the current behaviour of mypy is that you have to > import typing in the module before it will type check the module, so > that already gives you a way to skip type annotations on a per-module > basis: just don't import typing. > The current implementation of mypy will typecheck any module that uses annotations or imports from typing. -bob -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140814/7845ecc4/attachment.html>
- Previous message: [Python-ideas] Proposal: Use mypy syntax for function annotations
- Next message: [Python-ideas] Proposal: Use mypy syntax for function annotations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list