joke2k / faker

Faker is a Python package that generates fake data for you.
https://faker.readthedocs.io
MIT License
17.78k stars 1.93k forks source link

Call fake.zipcode_in_state('AZ'), the return zipcode not valid AZ zip code #2011

Closed pengdada00100 closed 3 months ago

pengdada00100 commented 8 months ago

Call fake.zipcode_in_state('AZ'), the return zipcode not valid AZ zip code

Steps to reproduce

Run code: `from faker import Faker

if name == "main": fake = Faker() f = fake.zipcode_in_state('AZ') print(f)`

get 85800 which not in AZ state

Expected behavior

The zip code should in AZ

Actual behavior

The zipcode not in AZ

stefan6419846 commented 8 months ago

The implementation is in https://github.com/joke2k/faker/blob/250fa19baf01aa2289afe44b07225f785cf536c5/faker/providers/address/en_US/__init__.py#L543-L547 Feel free to submit a corresponding PR.

lozik4 commented 8 months ago
  • Faker version: 24.0
  • OS:Macos

Call fake.zipcode_in_state('AZ'), the return zipcode not valid AZ zip code

Steps to reproduce

Run code: `from faker import Faker

if name == "main": fake = Faker() f = fake.zipcode_in_state('AZ') print(f)`

get 85800 which not in AZ state

Expected behavior

The zip code should in AZ

Actual behavior

The zipcode not in AZ

@pengdada00100 You can add locale to your code For example:

if __name__ == "__main__":
    fake = Faker("en_US") # add locale
    f = fake.zipcode_in_state('AZ')
    print(f)
tonyk232 commented 7 months ago

I think this issue can be closed. The problem is that not all 5 digits are valid ZIP codes, and faker can't create valid ones without checking them from a database/API.

However, 85775 is Tucson, AZ and 85901 is Show Low, AZ, so the randomly created 85800 is in the correct range for AZ.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.