Skip to main content

br-kit (Python)

Validação, formatação, parsing e geração de documentos brasileiros — zero dependências, pronto para o CNPJ alfanumérico (julho/2026).

Validation, formatting, parsing and generation of Brazilian documents — zero dependencies, ready for the alphanumeric CNPJ (July 2026).

API espelhada com o pacote npm br-kit (TS camelCase ↔ Py snake_case), com comportamento travado por uma suíte de vetores de conformidade compartilhada.

Instalação

pip install br-kit

Uso

from br_kit import cpf, cnpj, currency

cpf.is_valid("390.533.447-05")            # True
cpf.format("39053344705")                 # "390.533.447-05"
cpf.validate_detailed("111.111.111-11")   # ValidationResult(valid=False, reason="repeated-digits")

cnpj.is_valid("12.ABC.345/01DE-35")       # True  ← alfanumérico
cnpj.is_alphanumeric("12ABC34501DE35")    # True

currency.format_brl(1234.56)              # "R$ 1.234,56"
currency.parse_brl("R$ 1.234,56")         # 1234.56

Import granular: from br_kit.cpf import is_valid.

API (v0.1)

Módulo Funções
cpf is_valid · validate_detailed · format · strip · generate
cnpj is_valid · is_alphanumeric · validate_detailed · format · strip · generate
cep is_valid · format · strip
phone is_valid · parse · format · strip
currency format_brl · parse_brl
dates parse_pt_br · format_pt_br

Contrato (idêntico ao pacote npm, em snake_case):

  • is_valid(value) → bool, nunca levanta exceção.
  • validate_detailed(value) → ValidationResult(valid, reason). reason é estável: invalid-characters · invalid-length · repeated-digits · invalid-check-digit.
  • format(value) / parse(value) levantam ValueError em input inválido (em TypeScript: RangeError).
  • strip(value) remove a máscara; generate() é só para testes/fixtures — nunca trate o resultado como documento real.

Totalmente tipado (py.typed incluído). Documentação do algoritmo do CNPJ alfanumérico: docs/cnpj-alphanumeric.md.

✅ Pronto para o CNPJ alfanumérico (julho/2026)

A partir de julho de 2026 a Receita Federal emite CNPJs com letras (A–Z) nos 12 primeiros caracteres (IN RFB 2.229/2024). br-kit.cnpj valida ambos os formatos de forma transparente — \d{14} quebra, br-kit não.

Licença MIT. Documentação completa e suíte de conformidade: https://github.com/victorhurchella/br-kit

Metadata

Release files for br-kit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for br-kit 0.1.0
File Size Uploaded
br_kit-0.1.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for br-kit 0.1.0
File Interpreter ABI Platform
br_kit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / br_kit-0.1.0.tar.gz

Download URL br_kit-0.1.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cb9b40d83f1fbe6a25ed1d691c447c0ea6ec6ab7966e69a2c5053cd2d01f879b
BLAKE2b-256 checksum
How to use checksums
29c8ce57c3bd4c2965cbcf3cc54e7d44e5f1d6a6e3ffd82a89c57b1a017e0210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

Release files / br_kit-0.1.0-py3-none-any.whl

Download URL br_kit-0.1.0-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d86611583772b49051e8c25c3d797d5a371afd2b3eea4f9f6c3d903360890dbd
BLAKE2b-256 checksum
How to use checksums
0044ca369dbaeb0953197dfc2fdae9f774304aac7cb6cb66f58f2807c40cd18b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page