Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Utilitário `convert_name_to_uf`

### Fixed

- Suporte a anotações modernas no `brutils/cep.py` [#637](https://github.com/brazilian-utils/python/pull/637)

## [2.3.0] - 2025-10-07

### Added
Expand Down
16 changes: 9 additions & 7 deletions brutils/cep.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
############


def remove_symbols(dirty): # type: (str) -> str
def remove_symbols(dirty: str) -> str:
"""
Removes specific symbols from a given CEP (Postal Code).

Expand All @@ -34,7 +34,7 @@ def remove_symbols(dirty): # type: (str) -> str
return "".join(filter(lambda char: char not in ".-", dirty))


def format_cep(cep): # type: (str) -> str | None
def format_cep(cep: str) -> str | None:
"""
Formats a Brazilian CEP (Postal Code) into a standard format.

Expand Down Expand Up @@ -62,7 +62,7 @@ def format_cep(cep): # type: (str) -> str | None
############


def is_valid(cep): # type: (str) -> bool
def is_valid(cep: str) -> bool:
"""
Checks if a CEP (Postal Code) is valid.

Expand Down Expand Up @@ -92,7 +92,7 @@ def is_valid(cep): # type: (str) -> bool
return isinstance(cep, str) and len(cep) == 8 and cep.isdigit()


def generate(): # type: () -> str
def generate() -> str:
"""
Generates a random 8-digit CEP (Postal Code) number as a string.

Expand All @@ -113,7 +113,9 @@ def generate(): # type: () -> str


# Reference: https://viacep.com.br/
def get_address_from_cep(cep, raise_exceptions=False): # type: (str, bool) -> Address | None
def get_address_from_cep(
cep: str, raise_exceptions: bool = False
) -> Address | None:
"""
Fetches address information from a given CEP (Postal Code) using the ViaCEP API.

Expand Down Expand Up @@ -181,8 +183,8 @@ def get_address_from_cep(cep, raise_exceptions=False): # type: (str, bool) -> A


def get_cep_information_from_address(
federal_unit, city, street, raise_exceptions=False
): # type: (str, str, str, bool) -> list[Address] | None
federal_unit: str, city: str, street: str, raise_exceptions: bool = False
) -> list[Address] | None:
"""
Fetches CEP (Postal Code) options from a given address using the ViaCEP API.

Expand Down