Repository: brazilian-utils/brutils-python
Pull request #47 (2023-03-25 14:53:50)

refactor: improve imports usability for cpf

camilamaia: @antoniamaia testing
codecov[bot]: ## [Codecov](https://codecov.io/gh/brazilian-utils/brutils-python/pull/47?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils) Report
> Merging [#47](https://codecov.io/gh/brazilian-utils/brutils-python/pull/47?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils) (e8c0d4a) into [main](https://codecov.io/gh/brazilian-utils/brutils-python/commit/5f601cc83de8d816c1da9d54ed0defc00950e304?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils) (5f601cc) will **increase** coverage by `0.06%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
+ Coverage   96.36%   96.42%   +0.06%     
==========================================
  Files           2        3       +1     
  Lines          55       56       +1     
==========================================
+ Hits           53       54       +1     
  Misses          2        2              
```


| [Impacted Files](https://codecov.io/gh/brazilian-utils/brutils-python/pull/47?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils) | Coverage Δ | |
|---|---|---|
| [brutils/\_\_init\_\_.py](https://codecov.io/gh/brazilian-utils/brutils-python/pull/47?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils#diff-YnJ1dGlscy9fX2luaXRfXy5weQ==) | `100.00% <100.00%> (ø)` | |
| [brutils/cpf.py](https://codecov.io/gh/brazilian-utils/brutils-python/pull/47?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils#diff-YnJ1dGlscy9jcGYucHk=) | `96.00% <100.00%> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=brazilian-utils)


Patch:
diff --git a/README.md b/README.md
index e2afed4..84149a0 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ pip install brutils
 ```
 # numbers only, formatted as strings
 
->>> from brutils.cpf import is_valid_cpf
+>>> from brutils import is_valid_cpf
 >>> is_valid_cpf('00011122233')
 False
 >>> from brutils.cnpj import is_valid_cnpj
diff --git a/README_PT_BR.md b/README_PT_BR.md
index dd77209..8e4099a 100644
--- a/README_PT_BR.md
+++ b/README_PT_BR.md
@@ -32,7 +32,7 @@ pip install brutils
 ```
 # somente numeros, em formato string
 
->>> from brutils.cpf import is_valid_cpf
+>>> from brutils import is_valid_cpf
 >>> is_valid_cpf('00011122233')
 False
 >>> from brutils.cnpj import is_valid_cnpj
diff --git a/brutils/__init__.py b/brutils/__init__.py
index e69de29..00ddc61 100644
--- a/brutils/__init__.py
+++ b/brutils/__init__.py
@@ -0,0 +1,1 @@
+from brutils.cpf import is_valid as is_valid_cpf
diff --git a/brutils/cpf.py b/brutils/cpf.py
index 9b4486d..b8d3ead 100644
--- a/brutils/cpf.py
+++ b/brutils/cpf.py
@@ -71,7 +71,7 @@ def validate(cpf):  # type: (str) -> bool
     return all(hashdigit(cpf, i + 10) == int(v) for i, v in enumerate(cpf[9:]))
 
 
-def is_valid_cpf(cpf):  # type: (str) -> bool
+def is_valid(cpf):  # type: (str) -> bool
     """
     Returns whether or not the verifying checksum digits of the
     given `cpf` match it's base number. Input should be a digit


Test patch:
diff --git a/tests/test_cpf.py b/tests/test_cpf.py
index 322f08d..782161d 100644
--- a/tests/test_cpf.py
+++ b/tests/test_cpf.py
@@ -15,7 +15,7 @@ from brutils.cpf import (
     checksum,
     validate,
     generate,
-    is_valid_cpf,
+    is_valid,
 )
 from unittest import TestCase, main
 
@@ -50,10 +50,10 @@ class CPF(TestCase):
         assert validate("52599927765")
         assert not validate("00000000000")
 
-    def test_is_valid_cpf(self):
-        assert is_valid_cpf("52513127765")
-        assert is_valid_cpf("52599927765")
-        assert not is_valid_cpf("00000000000")
+    def test_is_valid(self):
+        assert is_valid("52513127765")
+        assert is_valid("52599927765")
+        assert not is_valid("00000000000")
 
     def test_generate(self):
         for i in range(1000):