{"id":7055,"library":"brazilnum","title":"brazilnum","description":"brazilnum is a Python library (version 0.8.8) designed for validating and working with various Brazilian identification numbers. It provides functions to validate CNPJ, CEI, CPF, PIS/PASEP, CEP, and municipal codes, which are essential for identifying firms, people, and places in Brazil. While the latest release was in October 2016, it remains a functional tool for these specific validation tasks.","status":"active","version":"0.8.8","language":"en","source_language":"en","source_url":"https://github.com/poliquin/brazilnum","tags":["brazil","brasil","validation","cpf","cnpj","cep","pis","pasep","cei","municipality"],"install":[{"cmd":"pip install brazilnum","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Validation functions are located in specific submodules.","wrong":"from brazilnum import is_cnpj","symbol":"is_cnpj","correct":"from brazilnum.cnpj import is_cnpj"},{"note":"Validation functions are located in specific submodules.","wrong":"from brazilnum import is_cpf","symbol":"is_cpf","correct":"from brazilnum.cpf import is_cpf"},{"note":"Validation functions are located in specific submodules.","wrong":"from brazilnum import is_cep","symbol":"is_cep","correct":"from brazilnum.cep import is_cep"},{"note":"Validation functions are located in specific submodules.","wrong":"from brazilnum import is_muni","symbol":"is_muni","correct":"from brazilnum.muni import is_muni"}],"quickstart":{"code":"from brazilnum.cnpj import is_cnpj\nfrom brazilnum.cpf import is_cpf\nfrom brazilnum.cep import is_cep\n\n# Example CNPJ validation\ncnpj_number = '00.000.000/0001-91'\nprint(f\"Is '{cnpj_number}' a valid CNPJ? {is_cnpj(cnpj_number)}\")\n\n# Example CPF validation\ncpf_number = '111.444.777-00'\nprint(f\"Is '{cpf_number}' a valid CPF? {is_cpf(cpf_number)}\")\n\n# Example CEP validation\ncep_number = '01001-000'\nprint(f\"Is '{cep_number}' a valid CEP? {is_cep(cep_number)}\")","lang":"python","description":"This quickstart demonstrates how to import and use the `is_cnpj`, `is_cpf`, and `is_cep` functions to validate common Brazilian identification numbers."},"warnings":[{"fix":"Be aware of its beta status and thoroughly test in your environment. Consider the lack of recent updates.","message":"The project is classified with a 'Development Status :: 4 - Beta' on PyPI. While functional, this indicates it might not be considered fully stable or actively developed for critical production environments.","severity":"gotcha","affected_versions":"0.8.8 and earlier"},{"fix":"Rely on the library's `is_muni` function for accurate validation, understanding that internal logic accounts for exceptions.","message":"Some true municipal (município) codes do not strictly follow the standard verification pattern. The library is designed to correctly handle these known exceptions, but it's important for users to be aware of this nuance rather than expecting all valid codes to conform to a simple mathematical rule.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Test thoroughly with your target Python 3 version before deploying. Consider forking or contributing updates if compatibility issues are found.","message":"The library was last updated in 2016 and explicitly states compatibility with Python 2.7 and 3. While PyPI also lists Python 3 support, users on very recent Python 3 versions (e.g., 3.10+) should perform compatibility testing, as issues might arise with newer language features or dependencies not present at the time of the last release.","severity":"gotcha","affected_versions":"All versions on Python 3.9+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Import specific validation functions from their respective submodules, like `from brazilnum.cpf import is_cpf`.","cause":"Attempting to import validation functions (e.g., `is_cpf`, `is_cnpj`) directly from the top-level `brazilnum` package.","error":"ModuleNotFoundError: No module named 'brazilnum.cpf'"},{"fix":"Use a direct import from the submodule: `from brazilnum.cnpj import is_cnpj`.","cause":"This error occurs when you import the main `brazilnum` package but then try to call a specific validation function directly from it, instead of importing it from its correct submodule.","error":"AttributeError: module 'brazilnum' has no attribute 'is_cnpj'"},{"fix":"Ensure the input string is correctly formatted according to Brazilian standards (e.g., with dots, hyphens, and slashes) before passing it to the validation function.","cause":"The input string provided for validation does not conform to the expected format (e.g., 'XX.XXX.XXX/YYYY-ZZ' for CNPJ, 'XXX.XXX.XXX-YY' for CPF, 'XXXXX-XXX' for CEP) or contains invalid characters. Some functions are strict about formatting.","error":"ValueError: Invalid CNPJ format (or similar for other types)"}]}