question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

quoted annotations + `from __future__ import annotations`

See original GitHub issue

should remove the quotes

need to be careful of:

  • Literal['foo']
  • Annotated (PEP 593)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Jan 2, 2021

you could add the import with reorder-python-imports --add-import 'from __future__ import annotations' – adding code isn’t really in the spirit of pyupgrade though

0reactions
henryiiicommented, Mar 11, 2021

For example, t: Annotated['MyClass', 'metadata'] can become t: Annotated[MyClass, 'metadata'] but not t: Annotated[MyClass, metadata], right? (Haven’t used Annotated yet, but I think it attaches just arbitrary metadata, “metadata” in this case). Same for many of the others, Literal has to always keep the strings, Union should always remove them, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

from __future__ import annotations - python - Stack Overflow
In python doc about __future__ there is a table below where it shows that annotations "optional in" 3.7.0b1 and "mandatory in" 4.0 but...
Read more >
__future__ — Future statement definitions — Python 3.11 ...
__future__ is a real module, and serves three purposes: ... OptionalRelease records the first release in which the feature was accepted. In the...
Read more >
Python Type Hints - How to Enable Postponed Evaluation ...
For files with from __future__ import annotations it automatically unquotes stringified type hints.
Read more >
Python __future__.annotations() Examples - ProgramCreek.com
This page shows Python examples of __future__.annotations. ... pass class A: b: B class B: pass ''') self.flakes(''' from __future__ import annotations def ......
Read more >
What are Python __future__ imports? - YouTube
Imports from the future !Python allows you to opt in to new features that are planned to change in future versions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found