@@ -68,12 +68,10 @@ def __init__(self, tag: str, *elements: Element) -> None:
68
68
69
69
def __str__ (self ) -> str :
70
70
"""Returns the Segment in Python list printout"""
71
- return "'{tag}' EDI segment: {elements}" .format (
72
- tag = self .tag , elements = str (self .elements )
73
- )
71
+ return f"'{ self .tag } ' EDI segment: { self .elements } "
74
72
75
73
def __repr__ (self ) -> str :
76
- return "{ } segment: {}" . format ( self . tag , str (self .elements ))
74
+ return f" { self . tag } segment: { str (self .elements )} "
77
75
78
76
def __eq__ (self , other ) -> bool :
79
77
# FIXME the other way round too? isinstance(other, type(self))?
@@ -125,16 +123,12 @@ def create_segment(name: str, *elements: Element, validate: bool = True) -> Segm
125
123
126
124
if not isinstance (name , str ):
127
125
raise EDISyntaxError (
128
- "The tag name of a segment must be a str, but is a {}: {}" .format (
129
- type (name ), name
130
- )
126
+ f"The tag name of a segment must be a str, but is a { type (name )} : { name } "
131
127
)
132
128
133
129
if not name .isalnum ():
134
130
raise EDISyntaxError (
135
- "Tag '{}': A tag name must only contain alphanumeric characters." .format (
136
- name
137
- )
131
+ f"Tag '{ name } ': A tag name must only contain alphanumeric characters."
138
132
)
139
133
140
134
for Plugin in SegmentProvider .plugins :
@@ -149,7 +143,7 @@ def create_segment(name: str, *elements: Element, validate: bool = True) -> Segm
149
143
if validate :
150
144
if not s .validate ():
151
145
raise EDISyntaxError (
152
- "could not create '{}' Segment. Validation failed." . format ( name )
146
+ f "could not create '{ name } ' Segment. Validation failed."
153
147
)
154
148
155
149
return s
0 commit comments