summaryrefslogtreecommitdiffstats
path: root/src/cepis/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/cepis/__init__.py')
-rw-r--r--src/cepis/__init__.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cepis/__init__.py b/src/cepis/__init__.py
index bc98d29..f32754a 100644
--- a/src/cepis/__init__.py
+++ b/src/cepis/__init__.py
@@ -24,8 +24,12 @@ Errors are explicit and split by decision — whether retrying helps or not::
try:
address = cepis.lookup(cep_from_form)
- except CEPNotFound:
- ... # the CEP does not exist: ask the user for another
+ except CEPNotFound as exc:
+ # The CEP does not exist. The API often knows which municipality it
+ # would have belonged to — enough to ask a better question than
+ # "invalid CEP". Still an error: `exc.faixa` is not an address.
+ if exc.faixa:
+ ... # f"no such CEP in {exc.faixa.label}"
except CepisError:
... # network, server, rate limit: retry later
@@ -41,7 +45,7 @@ this module. Anyone needing different settings should build their own.
from __future__ import annotations
-__version__ = "0.1.0"
+__version__ = "0.2.0"
from .client import DEFAULT_URL, MAX_BATCH, Client, normalize_cep
from .errors import (
@@ -53,7 +57,7 @@ from .errors import (
RateLimited,
ServerError,
)
-from .models import Address, Geo, Health
+from .models import Address, Faixa, Geo, Health
__all__ = [
"DEFAULT_URL",
@@ -62,6 +66,7 @@ __all__ = [
"CEPNotFound",
"CepisError",
"Client",
+ "Faixa",
"Geo",
"Health",
"InvalidCEP",