Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/code-quality-gate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ jobs:
run: poetry install --no-interaction --no-root
- name: Install project
run: poetry install --no-interaction
- name: Run lint
- name: Run all checks
run: |
poetry run task lint
poetry run task ci
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV

- name: Build site
run: mkdocs build
run: mkdocs build

- name: Deploy to GitHub Pages
run: mkdocs gh-deploy --force --clean
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,31 @@ repos:
hooks:
- id: check-yaml
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
hooks:
- id: ruff-check
types_or: [python, pyi]
args: [--fix]

- id: ruff-format
types_or: [python, pyi]

- repo: local
hooks:
- id: mypy
name: run mypy for type checking
entry: poetry run mypy --show-error-codes --ignore-missing-imports .
language: system
pass_filenames: false
files: \.py$

- repo: local
hooks:
- id: pytest
name: run pytest for automatic testing
entry: poetry run pytest
language: system
pass_filenames: false
files: \.py$
19 changes: 13 additions & 6 deletions CONTRIBUTING-pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,27 @@ Siga os passos abaixo para começar:
poetry install
```

4. **Crie uma nova branch para suas alterações**
4. **Instalando pre-commit hooks**
Para garantir a qualidade do código durante o desenvolvimento, usamos [pre-commit](https://pre-commit.com/).

```bash
poetry run pre-commit install
```

5. **Crie uma nova branch para suas alterações**
Escolha um nome descritivo para a branch:

```bash
git checkout -b nome-da-feature
```

5. **Execute os testes para garantir que tudo continua funcionando**
6. **Execute os testes para garantir que tudo continua funcionando**

```bash
poetry run task test
```

6. **Verifique a formatação e os padrões de código**
7. **Verifique a formatação e os padrões de código**
O comando de testes já verifica o estilo do código com o [Ruff](https://docs.astral.sh/ruff/).
Caso necessário, corrija manualmente com:

Expand All @@ -51,19 +58,19 @@ Siga os passos abaixo para começar:
poetry run task fmt
```

7. **Não esqueça de documentar suas alterações**
8. **Não esqueça de documentar suas alterações**
Para documentação nos utilizamos o [MKdocs](https://www.mkdocs.org/user-guide/).
Também usamos [MKdocstrings](https://mkdocstrings.github.io/) para gerar a referência a partir de docstrings, portanto não esqueça de documentar suas funções e módulos devidamente.

8. **Faça commit e envie suas alterações**
9. **Faça commit e envie suas alterações**

```bash
git add .
git commit -m "Adiciona feature ou correção: descrição curta"
git push origin nome-da-feature
```

9. **Abra um Pull Request no GitHub** e descreva suas alterações com clareza.
10. **Abra um Pull Request no GitHub** e descreva suas alterações com clareza.

---

Expand Down
19 changes: 13 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,27 @@ We welcome contributions to the **AbacatePay SDK**! Follow the steps below to ge
poetry install
```

4. **Create a new branch for your changes**
4. **Install pre-commit hooks**
To ensure consistent code quality during development, we use [pre-commit](https://pre-commit.com/) hooks.

```bash
poetry run pre-commit install
```

5. **Create a new branch for your changes**
Use a descriptive name for the feature or fix:

```bash
git checkout -b feature-name
```

5. **Run the tests** to ensure nothing is broken:
6. **Run the tests** to ensure nothing is broken:

```bash
poetry run task test
```

6. **Check code style and formatting**
7. **Check code style and formatting**
The test command will also check code style using [Ruff](https://docs.astral.sh/ruff/).
If formatting issues remain, you can fix them manually:

Expand All @@ -50,19 +57,19 @@ We welcome contributions to the **AbacatePay SDK**! Follow the steps below to ge
poetry run task fmt
```

7. **Don't forget to document your changes**
8. **Don't forget to document your changes**
We use [MKDocs](https://www.mkdocs.org/user-guide/) for documentation.
We also use [MKDocStrings](https://mkdocstrings.github.io/) to generate reference documentation from docstrings, so make sure to properly document your functions and modules.

8. **Commit and push your changes**
9. **Commit and push your changes**

```bash
git add .
git commit -m "Add feature or fix: short description"
git push origin feature-name
```

9. **Open a pull request** on GitHub and describe your changes clearly.
10. **Open a pull request** on GitHub and describe your changes clearly.

---

Expand Down
8 changes: 4 additions & 4 deletions abacatepay/customers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ class Customer(CustomerInline):
@property
def tax_id(self) -> str:
"""the customer identification (CPF or CNPJ)."""
return self.metadata.tax_id
return self.metadata.tax_id # type: ignore

@property
def name(self) -> str:
"""the customer's name"""
return self.metadata.name
return self.metadata.name # type: ignore

@property
def email(self) -> str:
"""the customer's email"""
return self.metadata.email
return self.metadata.email # type: ignore

@property
def cellphone(self) -> str:
"""the customer's phone number"""
return self.metadata.cellphone
return self.metadata.cellphone # type: ignore
9 changes: 5 additions & 4 deletions abacatepay/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __str__(self) -> str:
class InternalServerError(APIStatusError):
"""The request was unsuccessful due to an internal server error."""

status_code: Literal[500] = 500
status_code: Literal[HTTPStatus.INTERNAL_SERVER_ERROR]

def __init__(self, response: ResponseType) -> None:
super().__init__(
Expand All @@ -165,25 +165,26 @@ def __init__(self, response: ResponseType) -> None:
),
response=response,
)
self.status_code = HTTPStatus.INTERNAL_SERVER_ERROR


def raise_for_status(response: ResponseType) -> None:
code_exc_dict = {
code_exc_dict: dict[int, APIStatusError] = {
HTTPStatus.BAD_REQUEST: BadRequestError(response=response),
HTTPStatus.UNAUTHORIZED: UnauthorizedRequest(response=response),
HTTPStatus.FORBIDDEN: ForbiddenRequest(response=response),
HTTPStatus.NOT_FOUND: NotFoundError(response=response),
HTTPStatus.INTERNAL_SERVER_ERROR: InternalServerError(response=response),
}

code = response.status_code
code = HTTPStatus(response.status_code)
if code == HTTPStatus.OK:
return

if code not in code_exc_dict and code >= HTTPStatus.BAD_REQUEST:
raise APIStatusError(message=response.text, response=response)

raise code_exc_dict.get(
response.status_code,
HTTPStatus(response.status_code),
APIError(message=response.text, request=response.request),
)
19 changes: 13 additions & 6 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,27 @@ Siga os passos abaixo para começar:
poetry install
```

4. **Crie uma nova branch para suas alterações**
4. **Instalando pre-commit hooks**
Para garantir a qualidade do código durante o desenvolvimento, usamos [pre-commit](https://pre-commit.com/).

```bash
poetry run pre-commit install
```

5. **Crie uma nova branch para suas alterações**
Escolha um nome descritivo para a branch:

```bash
git checkout -b nome-da-feature
```

5. **Execute os testes para garantir que tudo continua funcionando**
6. **Execute os testes para garantir que tudo continua funcionando**

```bash
poetry run task test
```

6. **Verifique a formatação e os padrões de código**
7. **Verifique a formatação e os padrões de código**
O comando de testes já verifica o estilo do código com o [Ruff](https://docs.astral.sh/ruff/).
Caso necessário, corrija manualmente com:

Expand All @@ -50,19 +57,19 @@ Siga os passos abaixo para começar:
poetry run task fmt
```

7. **Não esqueça de documentar suas alterações**
8. **Não esqueça de documentar suas alterações**
Para documentação nos utilizamos o [MKdocs](https://www.mkdocs.org/user-guide/).
Também usamos [MKdocstrings](https://mkdocstrings.github.io/) para gerar a referência a partir de docstrings, portanto não esqueça de documentar suas funções e módulos devidamente.

8. **Faça commit e envie suas alterações**
9. **Faça commit e envie suas alterações**

```bash
git add .
git commit -m "Adiciona feature ou correção: descrição curta"
git push origin nome-da-feature
```

9. **Abra um Pull Request no GitHub** e descreva suas alterações com clareza.
10. **Abra um Pull Request no GitHub** e descreva suas alterações com clareza.

---

Expand Down
Loading