Skip to content

Commit 6845234

Browse files
author
PR Eval
committed
Merge branch 'pr-2383'
2 parents b3db1b2 + 62e7808 commit 6845234

2 files changed

Lines changed: 6404 additions & 0 deletions

File tree

faker2/providers/address/en_US/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional, Tuple
33

44
from ..en import Provider as AddressProvider
5+
from .counties import ALL_COUNTIES, COUNTIES_BY_STATE
56

67

78
class Provider(AddressProvider):
@@ -447,6 +448,22 @@ class Provider(AddressProvider):
447448
"PW",
448449
)
449450

451+
counties = ALL_COUNTIES
452+
counties_by_state = COUNTIES_BY_STATE
453+
454+
def county(self) -> str:
455+
return self.random_element(self.counties)
456+
457+
def county_by_state(self, state: Optional[str] = None) -> str:
458+
if state is None:
459+
state = self.random_element(list(self.counties_by_state))
460+
return self.random_element(self.counties_by_state[state])
461+
462+
def county_with_state(self) -> str:
463+
state = self.random_element(list(self.counties_by_state))
464+
county = self.random_element(self.counties_by_state[state])
465+
return f"{county}, {state}"
466+
450467
known_usps_abbr = states_abbr + territories_abbr + freely_associated_states_abbr
451468

452469
military_state_abbr = ("AE", "AA", "AP")

0 commit comments

Comments
 (0)