Skip to content

Commit 491ebc1

Browse files
committed
Don't crash with generics that have dotted names.
1 parent 600b4aa commit 491ebc1

4 files changed

Lines changed: 5 additions & 1 deletion

File tree

doc-source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Bugs Fixed
1010

1111
* :func:`formate.reformat_file` -- Only write to the file if there have been any changes.
1212
This avoids unnecessary changes to the mtime.
13+
* :mod:`formate.reformat_generics` -- Don't crash if a generic's name contains a ``.``.
1314

1415

1516
0.4.7

formate.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use_parentheses = true
3232
remove_redundant_aliases = true
3333
default_section = "THIRDPARTY"
3434
known_third_party = [
35+
"astatine",
3536
"asttokens",
3637
"attr_utils",
3738
"attrs",

formate/reformat_generics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from io import StringIO
4949

5050
# 3rd party
51+
import astatine
5152
import asttokens # type: ignore
5253
from domdf_python_tools.stringlist import DelimitedList, StringList
5354
from domdf_python_tools.words import TAB
@@ -204,7 +205,7 @@ def visit_Attribute(self, node: ast.Attribute) -> None: # noqa: D102
204205

205206
def visit_Subscript(self, node: ast.Subscript) -> None: # noqa: D102
206207
union = Generic(
207-
node.value.id, # type: ignore
208+
'.'.join(astatine.get_attribute_name(node.value)),
208209
UnionVisitor().visit(get_slice_value(node.slice)),
209210
)
210211
self.structure.append(union)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
astatine>=0.3.1
12
asttokens>=2.0.4
23
attr-utils>=0.5.5
34
attrs>=20.3.0

0 commit comments

Comments
 (0)