Giter Site home page Giter Site logo

brazilian-utils / brutils-python Goto Github PK

View Code? Open in Web Editor NEW
167.0 5.0 28.0 486 KB

Biblioteca de utilitários projetada para validar, gerar e manipular dados de acordo com as particularidades do Brasil 🇧🇷

Home Page: https://pypi.python.org/pypi/brutils

License: MIT License

Python 99.63% Makefile 0.37%
python cpf cnpj validation brazil pip email pis placa-de-carro processo-juridico

brutils-python's Introduction

🇧🇷 Brazilian Utils

Utils library for Brazilian-specific businesses.

📖 Documentation

Build Status Coverage Status Known Vulnerabilities Maintainability Downloads per month License: MIT


Vidas Negras Importam | Black Lives Matter. ✊🏽✊🏾✊🏿

To know how to help, just go to Vidas Negras Importam or Black Lives Matter.


We are changing

After one year of Brazilian Utils and lots of feedback, we decided to refactor our library to fix issues, create a website and make it easier for other developers to contribute. If you use v0 version, please, check v0 branch.


Table of Contents

Getting Started

Brazilian Utils is a library focused on solving problems that we face daily in the development of applications for the Brazilian business.

Installation

Using Brazilian Utils is quite simple and you can use it in some ways:

as npm package:

npm install --save @brazilian-utils/brazilian-utils

with yarn package manager:

yarn add @brazilian-utils/brazilian-utils

or <script> tag (global brazilianUtils):

<script src="https://unpkg.com/@brazilian-utils/brazilian-utils/dist/brazilian-utils.cjs.production.min.js"></script>

Usage

To use one of our utilities you just need to import the required function as in the example below:

import { isValidCPF } from '@brazilian-utils/brazilian-utils';

isValidCPF('1232454233345'); // false

You can check a list of utilities by clicking here.

Contributors

Our "thank you" goes to these wonderful people (emoji key):


Hyan Mandian

💻 📖 🤔 ⚠️

Lucas Veloso

💻 📖 🤔 ⚠️

Andreo Vieira

💻 📖 🤔 🔧

Matheus Almeida

💻 📖 ⚠️

Fernando Rogelin

💻 📖 ⚠️

rodineijf

💻 📖 ⚠️

Emerson Laurentino

💻 📖 ⚠️

Leonardo Dutra

💻 📖 ⚠️

Victor Magalhães

💻 🔧

Amauri Dias

💻 🔧

Felipe F. Diogo

💻 ⚠️

Alan Raso

💻 ⚠️

Felipe Fetter

📖

Rafael Franco

💻 📖

Rafael Pezzetti

💻 ⚠️ 📖

Antonio Roberto Furlaneto

💻 📖 ⚠️

Felipe Nolleto Nascimento

💻 📖 ⚠️

Saulo Joab

📖

Pedro Arantes

💻 📖 ⚠️

Silvio Clécio

💻 📖 ⚠️

Lucas Nascimento

💻

Lincon Kusunoki

💻 📖 ⚠️

Marcelo Cristiano

💻 📖 ⚠️

Tarcísio Batista de Freitas Junior

📖

Lucas Carrias

📖 ⚠️ 💻 🔧

This project follows the all-contributors specification. Contributions of any kind are welcome!

License

MIT

brutils-python's People

Contributors

antoniamaia avatar anurag-nagpal avatar camilamaia avatar cuducos avatar dependabot[bot] avatar giovannism20 avatar gtkacz avatar hebertn88 avatar jhonatacaiob avatar joseevilasio avatar kaioduarte avatar luizberti avatar magnunleno avatar marcelfox avatar patricia-salles avatar pontes-guilherme avatar vperon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

brutils-python's Issues

Add .gitignore fille

Add .gitignore file to avoid pushing files that we should not, like:

~/workspace/brutils-python  main ✗                                                                     1h47m ◒
▶ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	brutils/__pycache__/
	tests/__pycache__/

nothing added to commit but untracked files present (use "git add" to track)

Formatação de CEPs

Implementar um utilitário que recebe um CEP apenas com dígitos e retorna o CEP com símbolos (ponto e traço)

Criar mais testes para o utilitário is_valid_cnpj

Criar mais casos de teste para o utilitário is_valid_cnpj.

Alguns exemplos:

  • testar quando o input não é uma string
  • testar quando o input não tem o tamanho correto
  • testar quando o input não contém apenas dígitos

Você pode utilizar o exemplo do CPF como base:

def test_is_valid(self):

O algoritmo considerado para validação é este: https://www.geradorcnpj.com/algoritmo_do_cnpj.htm

Lembre-se também que você pode consultar como foi feita a implementação na biblioteca JS: https://github.com/brazilian-utils/brazilian-utils/tree/main/src/utilities/cnpj

Fix make install

It should be

install:
	@poetry install
	@poetry run pre-commit install -f -t pre-commit --hook-type commit-msg

instead of:

install:
	@poetry run pre-commit install -f -t pre-commit --hook-type commit-msg
	@poetry install

Remover Símbolos de CEPs

Implementar um utilitário que recebe um CEP com símbolos (ponto e traço) e retorna esse CEP apenas com dígitos

Criar um Código de Conduta para o repositório

  1. Criar um arquivo na raíz do projecto chamado CODE_OF_CONDUCT.md. Ele deve conter o Código de Conduta do repositório em português.
  2. Criar um arquivo na raíz do projecto chamado CODE_OF_CONDUCT_EN.md. Ele deve conter o Código de Conduta do repositório em inglês.

Sobre Código de Conduta:

Exemplos:

Melhorar format_cnpj e o seus testes

  1. Chamar a função is_valid e formatar o cnpj, sem utilizar o método display.
    Código referência:

    def format_cpf(cpf): # type: (str) -> str
    """
    Format an adequately formatted numbers-only CPF string,
    Returns a cpf formatted with standard visual aid symbols.
    Returns None if cpf is invalid.
    """
    if not is_valid(cpf):
    return None
    return "{}.{}.{}-{}".format(cpf[:3], cpf[3:6], cpf[6:9], cpf[9:])

  2. Melhorar os testes da função format_cnpj:

Código referência:

def test_format_cpf(self):
with patch("brutils.cpf.is_valid", return_value=True) as mock_is_valid:
# When cpf is_valid, returns formatted cpf
assert format_cpf("11144477735") == "111.444.777-35"
# Checks if function is_valid_cpf is called
mock_is_valid.assert_called_once_with("11144477735")
with patch("brutils.cpf.is_valid", return_value=False) as mock_is_valid:
# When cpf isn't valid, returns None
assert format_cpf("11144477735") is None

Adicionar flake8

https://flake8.pycqa.org/en/latest/

  1. Adicionar flake8 como dependência dev:
    [tool.poetry.group.dev.dependencies]
    black = "^23.3.0"
    pre-commit = "^2.21.0"
  2. Rodar o flake8 no comando make format. Análogo ao black:
    @poetry run black -l 80 . --exclude=.venv

O comando make format deve rodar tanto o black quanto o flake8, algo como:

format:
	@poetry run black -l 80 . --exclude=.venv
        @poetry run flake8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.