Skip to content

Commit

Permalink
Update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
harupy committed Jul 16, 2023
1 parent 451d7a6 commit a036ec7
Showing 1 changed file with 68 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s
5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014
6 |
7 | # with default values as list
7 | # with namespace
|
= help: Convert `MyType` to class syntax

Expand All @@ -20,66 +20,93 @@ UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s
6 |+ a: int
7 |+ b: tuple[str, ...]
6 8 |
7 9 | # with default values as list
8 10 | MyType = NamedTuple(
7 9 | # with namespace
8 10 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)])

UP014.py:15:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
|
14 | # with namespace
15 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)])
7 | # with namespace
8 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014
16 |
17 | # too many default values (OK)
9 |
10 | # invalid identifiers (OK)
|
= help: Convert `MyType` to class syntax

Suggested fix
12 12 | )
13 13 |
14 14 | # with namespace
15 |-MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)])
15 |+class MyType(typing.NamedTuple):
16 |+ a: int
17 |+ b: str
16 18 |
17 19 | # too many default values (OK)
18 20 | MyType = NamedTuple(
5 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])])
6 6 |
7 7 | # with namespace
8 |-MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)])
8 |+class MyType(typing.NamedTuple):
9 |+ a: int
10 |+ b: str
9 11 |
10 12 | # invalid identifiers (OK)
11 13 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])])

UP014.py:28:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
|
27 | # no fields
28 | MyType = typing.NamedTuple("MyType")
13 | # no fields
14 | MyType = typing.NamedTuple("MyType")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014
29 |
30 | # empty fields
15 |
16 | # empty fields
|
= help: Convert `MyType` to class syntax

Suggested fix
25 25 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])])
26 26 |
27 27 | # no fields
28 |-MyType = typing.NamedTuple("MyType")
28 |+class MyType(typing.NamedTuple):
29 |+ pass
29 30 |
30 31 | # empty fields
31 32 | MyType = typing.NamedTuple("MyType", [])
11 11 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])])
12 12 |
13 13 | # no fields
14 |-MyType = typing.NamedTuple("MyType")
14 |+class MyType(typing.NamedTuple):
15 |+ pass
15 16 |
16 17 | # empty fields
17 18 | MyType = typing.NamedTuple("MyType", [])

UP014.py:31:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
|
30 | # empty fields
31 | MyType = typing.NamedTuple("MyType", [])
16 | # empty fields
17 | MyType = typing.NamedTuple("MyType", [])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014
18 |
19 | # keywords
|
= help: Convert `MyType` to class syntax

Suggested fix
28 28 | MyType = typing.NamedTuple("MyType")
29 29 |
30 30 | # empty fields
31 |-MyType = typing.NamedTuple("MyType", [])
31 |+class MyType(typing.NamedTuple):
32 |+ pass
14 14 | MyType = typing.NamedTuple("MyType")
15 15 |
16 16 | # empty fields
17 |-MyType = typing.NamedTuple("MyType", [])
17 |+class MyType(typing.NamedTuple):
18 |+ pass
18 19 |
19 20 | # keywords
20 21 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...])

UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax
|
19 | # keywords
20 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014
21 |
22 | # unfixable
|
= help: Convert `MyType` to class syntax

Suggested fix
17 17 | MyType = typing.NamedTuple("MyType", [])
18 18 |
19 19 | # keywords
20 |-MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...])
20 |+class MyType(typing.NamedTuple):
21 |+ a: int
22 |+ b: tuple[str, ...]
21 23 |
22 24 | # unfixable
23 25 | MyType = typing.NamedTuple("MyType", [("a", int)], [("b", str)])


0 comments on commit a036ec7

Please sign in to comment.