Add rule to upgrade type alias annotations to keyword (UP040) (#6289)

Adds rule to convert type aliases defined with annotations i.e. `x:
TypeAlias = int` to the new PEP-695 syntax e.g. `type x = int`.

Does not support using new generic syntax for type variables, will be
addressed in a follow-up.
Added as part of pyupgrade — ~the code 100 as chosen to avoid collision
with real pyupgrade codes~.

Part of #4617 
Builds on #5062
This commit is contained in:
Zanie Blue
2023-08-03 11:13:06 -05:00
committed by GitHub
parent c75e8a8dab
commit 718e3945e3
11 changed files with 214 additions and 7 deletions

View File

@@ -82,6 +82,7 @@ KNOWN_PARSE_ERRORS = [
"missing-newline-at-end-of-file",
"mixed-spaces-and-tabs",
"no-indented-block",
"non-pep695-type-alias", # requires Python 3.12
"tab-after-comma",
"tab-after-keyword",
"tab-after-operator",