Skip to content

Commit

Permalink
Merge pull request #245 from taconi/244
Browse files Browse the repository at this point in the history
Removendo instalação do `pydantic[email]`
  • Loading branch information
dunossauro authored Sep 26, 2024
2 parents cb5a141 + c43f810 commit d33e3a4
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 54 deletions.
18 changes: 1 addition & 17 deletions aulas/03.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ No desenvolvimento de APIs, existem quatro ações principais que fazemos com os
CRUD é um acrônimo que representa as quatro operações básicas que você pode realizar em qualquer banco de dados persistente:

- **C**reate (Criar): adicionar novos registros ao banco de dados.
- **R**ead (Ler): recuperar registros existentes do banco de dados.
- **R**ead (Ler): recuperar registros existentes do banco de dados.
- **U**pdate (Atualizar): modificar registros existentes no banco de dados.
- **D**elete (Excluir): remover registros existentes do banco de dados.

Expand Down Expand Up @@ -275,22 +275,6 @@ class UserPublic(BaseModel):
email: EmailStr
```

Embora essa seja um definição valida do schema, o pydantic depende que a extensão de emails seja instalada em nosso ambiente. Ao executar o servidor, podemos ver que o erro é bastante descritivo:

```python
File "<...>/.venv/<...>/pydantic/networks.py", line 354, in import_email_validator
raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') from e
ImportError: email-validator is not installed, run `pip install pydantic[email]`
```

Traduzindo de forma literal, teríamos algo como: `#!python ImportError: email-validator não está instalado, rode 'pip install pydantic[email]'`.

Como estamos usando o poetry como gerenciador de pacotes, podemos executar dessa forma:

```shell title="$ Execução no terminal!"
poetry add "pydantic[email]"
```

Com isso, o pydantic irá oferecer um exemplo de email no swagger `"[email protected]"` e acerta os schemas para fazer essas validações:

![descrição](assets/03/schema_com_email_no_swagger.png){: .center .shadow }
Expand Down
3 changes: 1 addition & 2 deletions codigo_das_aulas/03/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion codigo_das_aulas/03/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.3"
Expand Down
3 changes: 1 addition & 2 deletions codigo_das_aulas/04/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/04/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -47,4 +46,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
3 changes: 1 addition & 2 deletions codigo_das_aulas/05/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/05/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -47,4 +46,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
3 changes: 1 addition & 2 deletions codigo_das_aulas/06/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/06/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -51,4 +50,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
3 changes: 1 addition & 2 deletions codigo_das_aulas/07/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion codigo_das_aulas/07/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down
3 changes: 1 addition & 2 deletions codigo_das_aulas/08/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion codigo_das_aulas/08/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down
3 changes: 1 addition & 2 deletions codigo_das_aulas/09/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/09/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -53,4 +52,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
3 changes: 1 addition & 2 deletions codigo_das_aulas/10/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/10/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -54,4 +53,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
3 changes: 1 addition & 2 deletions codigo_das_aulas/11/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/11/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -54,4 +53,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
3 changes: 1 addition & 2 deletions codigo_das_aulas/12/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions codigo_das_aulas/12/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [{include = "fast_zero"}]
[tool.poetry.dependencies]
python = "^3.11"
fastapi = {extras = ["standard"], version = "^0.115.0"}
pydantic = {extras = ["email"], version = "^2.9.2"}
sqlalchemy = "^2.0.35"
pydantic-settings = "^2.5.2"
alembic = "^1.13.3"
Expand Down Expand Up @@ -54,4 +53,4 @@ post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"

0 comments on commit d33e3a4

Please sign in to comment.