Skip to content

Commit 3f1c206

Browse files
derek73claude
andcommitted
Replace Python 2-era set([...]) constructors with set literals
Set literals arrived in Python 2.7/3.0; the set([...])-around-a-list form predates them. Purely cosmetic: contents verified identical against master for all eight constants. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b5bef9a commit 3f1c206

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

nameparser/config/conjunctions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CONJUNCTIONS = set([
1+
CONJUNCTIONS = {
22
'&',
33
'and',
44
'et',
@@ -7,7 +7,7 @@
77
'the',
88
'und',
99
'y',
10-
])
10+
}
1111
"""
1212
Pieces that should join to their neighboring pieces, e.g. "and", "y" and "&".
1313
"of" and "the" are also include to facilitate joining multiple titles,

nameparser/config/prefixes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#: means that name is not auto-fixed, whereas a wrong member misparses a real
1010
#: person. Must stay a subset of :py:data:`PREFIXES` and disjoint from
1111
#: :py:data:`~nameparser.config.bound_first_names.BOUND_FIRST_NAMES`.
12-
NON_FIRST_NAME_PREFIXES = set([
12+
NON_FIRST_NAME_PREFIXES = {
1313
"'t",
1414
'af',
1515
'auf',
@@ -32,7 +32,7 @@
3232
'vd',
3333
'vom',
3434
'zu',
35-
])
35+
}
3636

3737
#: Name pieces that appear before a last name. Prefixes join to the piece
3838
#: that follows them to make one new piece. They can be chained together, e.g
@@ -48,7 +48,7 @@
4848
#: is guaranteed to also be a prefix (and still join forward), with no drift --
4949
#: mirroring ``TITLES = FIRST_NAME_TITLES | {...}`` in
5050
#: :py:mod:`nameparser.config.titles`.
51-
PREFIXES = NON_FIRST_NAME_PREFIXES | set([
51+
PREFIXES = NON_FIRST_NAME_PREFIXES | {
5252
'aan',
5353
'aen',
5454
'abu',
@@ -86,7 +86,7 @@
8686
'vander',
8787
'vel',
8888
'von',
89-
])
89+
}
9090

9191
# Guard the two invariants the docstring above promises, so a future edit that
9292
# breaks them fails at import time instead of silently drifting until a test

nameparser/config/suffixes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SUFFIX_NOT_ACRONYMS = set([
1+
SUFFIX_NOT_ACRONYMS = {
22
'dr',
33
'esq',
44
'esquire',
@@ -21,14 +21,14 @@
2121
# literally instead of going through nickname/suffix disambiguation).
2222
'ret',
2323
'vet',
24-
])
24+
}
2525
"""
2626
2727
Post-nominal pieces that are not acronyms. The parser does not remove periods
2828
when matching against these pieces.
2929
3030
"""
31-
SUFFIX_ACRONYMS_AMBIGUOUS = set([
31+
SUFFIX_ACRONYMS_AMBIGUOUS = {
3232
# Suffix acronyms that also commonly work as given-name nicknames on
3333
# their own (e.g. "Ed", "JD"). Read only by HumanName.parse_nicknames()
3434
# when deciding whether parenthesized/quoted content is a nickname or a
@@ -42,15 +42,15 @@
4242
# certifications/degrees (e.g. 'mba', 'cpa', 'phd') don't need an entry.
4343
'ed',
4444
'jd',
45-
])
45+
}
4646
"""
4747
4848
Acronym suffixes from SUFFIX_ACRONYMS that also plausibly collide with a
4949
common given-name nickname. Not a partition of SUFFIX_ACRONYMS -- a small,
5050
standalone exception list consulted only by parse_nicknames().
5151
5252
"""
53-
SUFFIX_ACRONYMS = set([
53+
SUFFIX_ACRONYMS = {
5454
'8-vsb',
5555
'aas',
5656
'aba',
@@ -683,7 +683,7 @@
683683
'vcp',
684684
'vd',
685685
'vrd',
686-
])
686+
}
687687
"""
688688
689689
Post-nominal acronyms. Titles, degrees and other things people stick after their name

nameparser/config/titles.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FIRST_NAME_TITLES = set([
1+
FIRST_NAME_TITLES = {
22
'aunt',
33
'auntie',
44
'brother',
@@ -21,7 +21,7 @@
2121
'shaikh',
2222
'cheikh',
2323
'shekh',
24-
])
24+
}
2525
"""
2626
When these titles appear with a single other name, that name is a first name, e.g.
2727
"Sir John", "Sister Mary", "Queen Elizabeth".
@@ -31,7 +31,7 @@
3131
#: Many of these from wikipedia: https://en.wikipedia.org/wiki/Title.
3232
#: The parser recognizes chains of these including conjunctions allowing
3333
#: recognition titles like "Deputy Secretary of State".
34-
TITLES = FIRST_NAME_TITLES | set([
34+
TITLES = FIRST_NAME_TITLES | {
3535
"attaché",
3636
"chargé d'affaires",
3737
"king's",
@@ -683,4 +683,4 @@
683683
'woodman',
684684
'writer',
685685
'zoologist',
686-
])
686+
}

0 commit comments

Comments
 (0)