Skip to content

Commit eee6e72

Browse files
derek73claude
andcommitted
Normalize HumanName repr indentation and trailing whitespace
__repr__ mixed tabs with spaces and had inconsistent trailing spaces across attribute lines (some fields carried a stray trailing space before the newline, others didn't). Standardize on 4-space indentation with no trailing whitespace, and update the example blocks in README.rst, docs/usage.rst, and docs/customize.rst to match the real output. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 3008b48 commit eee6e72

4 files changed

Lines changed: 102 additions & 102 deletions

File tree

README.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ Quick Start Example
6969
>>> name = HumanName("Dr. Juan Q. Xavier de la Vega III (Doc Vega)")
7070
>>> name
7171
<HumanName : [
72-
title: 'Dr.'
73-
first: 'Juan'
74-
middle: 'Q. Xavier'
75-
last: 'de la Vega'
76-
suffix: 'III'
77-
nickname: 'Doc Vega'
78-
maiden: ''
72+
title: 'Dr.'
73+
first: 'Juan'
74+
middle: 'Q. Xavier'
75+
last: 'de la Vega'
76+
suffix: 'III'
77+
nickname: 'Doc Vega'
78+
maiden: ''
7979
]>
8080
>>> name.last
8181
'de la Vega'
@@ -99,13 +99,13 @@ and "post-nominal" would probably be better names.)
9999
>>> name = HumanName("1 & 2, 3 4 5, Mr.")
100100
>>> name
101101
<HumanName : [
102-
title: ''
103-
first: '3'
104-
middle: '4 5'
105-
last: '1 & 2'
106-
suffix: 'Mr.'
107-
nickname: ''
108-
maiden: ''
102+
title: ''
103+
first: '3'
104+
middle: '4 5'
105+
last: '1 & 2'
106+
suffix: 'Mr.'
107+
nickname: ''
108+
maiden: ''
109109
]>
110110

111111
Customization

docs/customize.rst

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -348,27 +348,27 @@ constant so that "Hon" can be parsed as a first name.
348348
>>> hn = HumanName("Hon Solo")
349349
>>> hn
350350
<HumanName : [
351-
title: 'Hon'
352-
first: ''
353-
middle: ''
354-
last: 'Solo'
355-
suffix: ''
356-
nickname: ''
357-
maiden: ''
351+
title: 'Hon'
352+
first: ''
353+
middle: ''
354+
last: 'Solo'
355+
suffix: ''
356+
nickname: ''
357+
maiden: ''
358358
]>
359359
>>> from nameparser.config import CONSTANTS
360360
>>> CONSTANTS.titles.remove('hon')
361361
SetManager({'right', ..., 'tax'})
362362
>>> hn = HumanName("Hon Solo")
363363
>>> hn
364364
<HumanName : [
365-
title: ''
366-
first: 'Hon'
367-
middle: ''
368-
last: 'Solo'
369-
suffix: ''
370-
nickname: ''
371-
maiden: ''
365+
title: ''
366+
first: 'Hon'
367+
middle: ''
368+
last: 'Solo'
369+
suffix: ''
370+
nickname: ''
371+
maiden: ''
372372
]>
373373

374374

@@ -403,13 +403,13 @@ making them lower case and removing periods.
403403
>>> hn = HumanName("Assoc Dean of Chemistry Robert Johns", constants=constants)
404404
>>> hn
405405
<HumanName : [
406-
title: 'Assoc Dean of Chemistry'
407-
first: 'Robert'
408-
middle: ''
409-
last: 'Johns'
410-
suffix: ''
411-
nickname: ''
412-
maiden: ''
406+
title: 'Assoc Dean of Chemistry'
407+
first: 'Robert'
408+
middle: ''
409+
last: 'Johns'
410+
suffix: ''
411+
nickname: ''
412+
maiden: ''
413413
]>
414414

415415

@@ -431,13 +431,13 @@ the config on one instance could modify the behavior of another instance.
431431
>>> other_instance = HumanName("Dean Robert Johns")
432432
>>> other_instance # Dean parses as title
433433
<HumanName : [
434-
title: 'Dean'
435-
first: 'Robert'
436-
middle: ''
437-
last: 'Johns'
438-
suffix: ''
439-
nickname: ''
440-
maiden: ''
434+
title: 'Dean'
435+
first: 'Robert'
436+
middle: ''
437+
last: 'Johns'
438+
suffix: ''
439+
nickname: ''
440+
maiden: ''
441441
]>
442442

443443

@@ -459,13 +459,13 @@ reference to the module-level config values with the behavior described above.
459459
>>> other_instance = HumanName("Dean Robert Johns", None) # <-- pass None for per-instance config
460460
>>> other_instance
461461
<HumanName : [
462-
title: ''
463-
first: 'Dean'
464-
middle: 'Robert'
465-
last: 'Johns'
466-
suffix: ''
467-
nickname: ''
468-
maiden: ''
462+
title: ''
463+
first: 'Dean'
464+
middle: 'Robert'
465+
last: 'Johns'
466+
suffix: ''
467+
nickname: ''
468+
maiden: ''
469469
]>
470470
>>> other_instance.has_own_config
471471
True
@@ -531,13 +531,13 @@ directly to the attribute.
531531
>>> hn.suffix = "Md."
532532
>>> hn.suffix
533533
<HumanName : [
534-
title: 'Associate Processor'
535-
first: 'John'
536-
middle: 'A. Kenneth'
537-
last: 'Doe'
538-
suffix: 'Md.'
539-
nickname: ''
540-
maiden: ''
534+
title: 'Associate Processor'
535+
first: 'John'
536+
middle: 'A. Kenneth'
537+
last: 'Doe'
538+
suffix: 'Md.'
539+
nickname: ''
540+
maiden: ''
541541
]>
542542

543543

docs/usage.rst

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ Requires Python 3.10+.
3434
>>> name.full_name = "Juan Q. Xavier Velasquez y Garcia, Jr."
3535
>>> name
3636
<HumanName : [
37-
title: ''
38-
first: 'Juan'
39-
middle: 'Q. Xavier'
40-
last: 'Velasquez y Garcia'
41-
suffix: 'Jr.'
42-
nickname: ''
43-
maiden: ''
37+
title: ''
38+
first: 'Juan'
39+
middle: 'Q. Xavier'
40+
last: 'Velasquez y Garcia'
41+
suffix: 'Jr.'
42+
nickname: ''
43+
maiden: ''
4444
]>
4545
>>> name.middle = "Jason Alexander"
4646
>>> name.middle
4747
'Jason Alexander'
4848
>>> name
4949
<HumanName : [
50-
title: ''
51-
first: 'Juan'
52-
middle: 'Jason Alexander'
53-
last: 'Velasquez y Garcia'
50+
title: ''
51+
first: 'Juan'
52+
middle: 'Jason Alexander'
53+
last: 'Velasquez y Garcia'
5454
suffix: 'Jr.'
5555
nickname: ''
5656
maiden: ''
@@ -139,13 +139,13 @@ available from the nickname attribute.
139139
>>> name = HumanName('Jonathan "John" A. Smith')
140140
>>> name
141141
<HumanName : [
142-
title: ''
143-
first: 'Jonathan'
144-
middle: 'A.'
145-
last: 'Smith'
146-
suffix: ''
147-
nickname: 'John'
148-
maiden: ''
142+
title: ''
143+
first: 'Jonathan'
144+
middle: 'A.'
145+
last: 'Smith'
146+
suffix: ''
147+
nickname: 'John'
148+
maiden: ''
149149
]>
150150

151151
Exception: content that looks like a suffix (a member of
@@ -161,13 +161,13 @@ written in parenthesis.
161161
>>> name = HumanName('Andrew Perkins (MBA)')
162162
>>> name
163163
<HumanName : [
164-
title: ''
165-
first: 'Andrew'
166-
middle: ''
167-
last: 'Perkins'
168-
suffix: 'MBA'
169-
nickname: ''
170-
maiden: ''
164+
title: ''
165+
first: 'Andrew'
166+
middle: ''
167+
last: 'Perkins'
168+
suffix: 'MBA'
169+
nickname: ''
170+
maiden: ''
171171
]>
172172

173173
A few suffix acronyms, listed in
@@ -182,13 +182,13 @@ reading in that ambiguous context:
182182
>>> name = HumanName('JEFFREY (JD) BRICKEN')
183183
>>> name
184184
<HumanName : [
185-
title: ''
186-
first: 'JEFFREY'
187-
middle: ''
188-
last: 'BRICKEN'
189-
suffix: ''
190-
nickname: 'JD'
191-
maiden: ''
185+
title: ''
186+
first: 'JEFFREY'
187+
middle: ''
188+
last: 'BRICKEN'
189+
suffix: ''
190+
nickname: 'JD'
191+
maiden: ''
192192
]>
193193

194194
Leading Period-Abbreviation Titles
@@ -208,13 +208,13 @@ word appearing after the first name is left as a middle name.
208208
>>> name = HumanName("Major. Dona Smith")
209209
>>> name
210210
<HumanName : [
211-
title: 'Major.'
212-
first: 'Dona'
213-
middle: ''
214-
last: 'Smith'
215-
suffix: ''
216-
nickname: ''
217-
maiden: ''
211+
title: 'Major.'
212+
first: 'Dona'
213+
middle: ''
214+
last: 'Smith'
215+
suffix: ''
216+
nickname: ''
217+
maiden: ''
218218
]>
219219
>>> name = HumanName("J. Smith")
220220
>>> name.first

nameparser/parser.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ def __repr__(self) -> str:
209209
_string = f"<{self.__class__.__name__} : [ Unparsable ] >"
210210
else:
211211
attrs = (
212-
f"\ttitle: {self.title or ''!r} \n"
213-
f"\tfirst: {self.first or ''!r} \n"
214-
f"\tmiddle: {self.middle or ''!r} \n"
215-
f"\tlast: {self.last or ''!r} \n"
216-
f"\tsuffix: {self.suffix or ''!r}\n"
217-
f"\tnickname: {self.nickname or ''!r}\n"
218-
f"\tmaiden: {self.maiden or ''!r}"
212+
f" title: {self.title or ''!r}\n"
213+
f" first: {self.first or ''!r}\n"
214+
f" middle: {self.middle or ''!r}\n"
215+
f" last: {self.last or ''!r}\n"
216+
f" suffix: {self.suffix or ''!r}\n"
217+
f" nickname: {self.nickname or ''!r}\n"
218+
f" maiden: {self.maiden or ''!r}"
219219
)
220220
_string = f"<{self.__class__.__name__} : [\n{attrs}\n]>"
221221
return _string

0 commit comments

Comments
 (0)