Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Sep 30, 2024
1 parent 2a25996 commit cb36020
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
22 changes: 8 additions & 14 deletions faker/providers/address/en_IN/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import random
from typing import Optional
from typing import Dict, Optional, Tuple

from faker.providers.address import Provider as AddressProvider


Expand Down Expand Up @@ -393,7 +393,7 @@ class Provider(AddressProvider):
"West Bengal",
)

states_abbr = (
states_abbr: Tuple[str, ...] = (
"AP",
"AR",
"AS",
Expand Down Expand Up @@ -497,7 +497,7 @@ class Provider(AddressProvider):
"PY": [(605_000, 605_999)],
}

army_pincode = {"APS": (900_000, 999_999)}
army_pincode: Dict[str, Tuple[int, int]] = {"APS": (900_000, 999_999)}

def city_name(self) -> str:
return self.random_element(self.cities)
Expand All @@ -512,9 +512,7 @@ def union_territory(self) -> str:

return self.random_element(self.union_territories)[0]

def pincode_in_state(
self, state_abbr: Optional[str] = None, include_union_territories=False
) -> int:
def pincode_in_state(self, state_abbr: Optional[str] = None, include_union_territories: bool = False) -> int:
"""Random PIN Code within provided state abbreviation
:param state_abbr: State Abbr, defaults to None
Expand Down Expand Up @@ -544,20 +542,16 @@ def pincode_in_state(
def pincode_in_military(self) -> int:
"""Random PIN Code within Army Postal Service range"""

key = self.random_element(self.army_pincode.keys())
key: str = self.random_element(self.army_pincode.keys())

return self.generator.random.randint(*self.army_pincode[key])

# Aliases

def zipcode_in_state(
self, state_abbr: Optional[str] = None, include_union_territories=False
) -> int:
def zipcode_in_state(self, state_abbr: Optional[str] = None, include_union_territories: bool = False) -> int:
return self.pincode_in_state(state_abbr, include_union_territories)

def postcode_in_state(
self, state_abbr: Optional[str] = None, include_union_territories=False
) -> int:
def postcode_in_state(self, state_abbr: Optional[str] = None, include_union_territories: bool = False) -> int:
return self.pincode_in_state(state_abbr, include_union_territories)

def pincode_in_army(self) -> int:
Expand Down
28 changes: 28 additions & 0 deletions faker/proxy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2955,6 +2955,34 @@ class Faker:
def province(self) -> str: ...
def province_abbr(self) -> str: ...
def county(self) -> str: ...
def pincode_in_army(self) -> int: ...
def pincode_in_military(self) -> int:
"""
Random PIN Code within Army Postal Service range
"""
...

def pincode_in_state(self, state_abbr: Optional[str] = ..., include_union_territories: bool = ...) -> int:
"""
Random PIN Code within provided state abbreviation
:param state_abbr: State Abbr, defaults to None
:param include_union_territories: Include Union Territories ?, defaults to False
:raises ValueError: If incorrect state abbr
:return: PIN Code
"""
...

def postcode_in_army(self) -> int: ...
def postcode_in_military(self) -> int: ...
def union_territory(self) -> str:
"""
Returns random union territory name
"""
...

def zipcode_in_army(self) -> int: ...
def zipcode_in_military(self) -> int: ...
def aadhaar_id(self) -> str:
"""
Aadhaar is a 12 digit person identifier generated for residents of
Expand Down

0 comments on commit cb36020

Please sign in to comment.