Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `is_valid_pis` aceitava dígitos de outros alfabetos, como `٩`, e levantava `ValueError` com algarismos sobrescritos, como `²` [#813](https://github.com/brazilian-utils/python/issues/813)
- Cálculo do dígito verificador em `is_valid_legal_process` e `generate_legal_process`, que rejeitava números de processo reais e gerava números inválidos [#785](https://github.com/brazilian-utils/python/pull/785)

## [2.5.0] - 2026-06-30
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ Referências:

Argumentos:

- pis (str): Número PIS como uma string com o comprimento apropriado.
- pis (str): Número PIS como uma string de 11 dígitos de 0 a 9.

Retorna:

Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ References:

Args:

- pis (str): PIS number as a string with the proper length.
- pis (str): PIS number as an 11-digit string of ASCII digits (0-9).

Returns:

Expand Down
3 changes: 2 additions & 1 deletion brutils/pis.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def is_valid(pis: str) -> bool:
given `PIS` match its base number.

Args:
pis (str): PIS number as a string of proper length.
pis (str): PIS number as an 11-digit string of ASCII digits (0-9).

Returns:
bool: True if PIS is valid, False otherwise.
Expand All @@ -82,6 +82,7 @@ def is_valid(pis: str) -> bool:
return (
isinstance(pis, str)
and len(pis) == 11
and pis.isascii()
and pis.isdigit()
and pis[-1] == str(_checksum(pis[:-1]))
)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_pis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ def test_is_valid(self):
self.assertIs(is_valid("123pis"), False)
self.assertIs(is_valid("123456789ab"), False)

# When PIS contains digits from other alphabets, returns False
self.assertIs(is_valid("١2038619494"), False)
self.assertIs(is_valid("12038619494"), False)

# When PIS contains superscript digits, returns False instead of
# raising ValueError
self.assertIs(is_valid("1203861949" + "⁴"), False)
self.assertIs(is_valid("²" * 11), False)

# When checksum digit doesn't match last digit, returns False
self.assertIs(is_valid("11111111111"), False)
self.assertIs(is_valid("11111111215"), False)
Expand Down
Loading