Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
156 lines (141 loc) · 3.66 KB
/
Copy pathpyproject.toml
File metadata and controls
156 lines (141 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# ============================
# Projeto
# Referência: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
#
# Instale o pacote: python-dotenv
# Mostrei como no README.md
#
# Os pontos de atenção estão comentados próximo das chaves, aqui só coloquei um
# lembrete.
#
# Atenção: As versões do Python devem ser consistentes entre:
# - project.requires-python
# - tool.ruff.target-version
# - tool.pyright.pythonVersion
#
# Atenção: O nome do pacote principal deve ser consistente entre:
# - project.scripts
# - tool.ruff.lint.isort.known-first-party
# - A pasta dentro de 'src/'
# ============================
[project]
name = "project1"
version = "0.0.1"
description = "project1"
readme = "README.md"
license = "MIT"
authors = [{ name = "Seu nome", email = "seu@email.com" }]
requires-python = ">=3.13"
dependencies = ["python-dotenv>=1.1.0"]
[project.urls]
Homepage = "https://www.otaviomiranda.com.br/"
# Documentation = "https://example.org"
# Repository = "https://github.com/me/spam.git"
# Issues = "https://github.com/me/spam/issues"
# Changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"
[project.optional-dependencies]
dev = ["ruff", "pyright", "pytest", "pytest-xdist"]
[project.scripts]
# Define os comandos de console. A chave ('project1') é o comando.
# O valor aponta para 'nome_do_pacote.nome_do_modulo:nome_da_funcao'.
# Ex: 'my_package.main:run' -> src/my_package/main.py (e a função run lá dentro).
# Lembre-se de sincronizar o nome do pacote com 'known-first-party' do Ruff.
project1 = "my_package.my_module:run_from_script"
# ============================
# Lint e formatação (Ruff)
# ============================
[tool.ruff]
line-length = 88
target-version = "py313"
fix = true
show-fixes = true
indent-width = 4
exclude = ["venv", ".venv", "env", ".env", "node_modules", "__pycache__"]
[tool.ruff.lint]
select = [
"ASYNC",
"A",
"ANN",
"B",
"BLE",
"C4",
"C90",
"COM",
"E",
"EM",
"ERA",
"EXE",
"F",
"FBT",
"FIX",
"I",
"ICN",
"ISC",
"Q",
"RET",
"RSE",
"S",
"SIM",
"SLF",
"T10",
"T20",
"TC",
"TD",
"TRY",
"UP",
"W",
"YTT",
"RUF",
"N",
]
ignore = ["T201", "COM812"]
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["ANN201", "S101"]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "lf"
[tool.ruff.lint.isort]
# Ensina ao Ruff qual é o pacote principal do seu projeto.
# Deve ser o mesmo nome da pasta dentro de 'src/'.
known-first-party = ["my_package"]
# ============================
# Tipagem (Pyright)
# ============================
[tool.pyright]
typeCheckingMode = "strict"
pythonVersion = "3.13"
include = ["src", 'tests']
exclude = [
"**/venv",
"**/.venv",
"**/env",
"**/.env",
"**/node_modules",
"**/__pycache__",
]
venv = ".venv"
venvPath = "."
executionEnvironments = [{ root = "src" }]
# ============================
# Testes (Pytest)
# ============================
[tool.pytest.ini_options]
addopts = "-s --color=yes --tb=short"
# Adiciona 'src' ao path do Python durante os testes. Isso permite que
# os testes em `tests/` importem os módulos de `src/` sem erros.
pythonpath = ["src"]
testpaths = ["tests"]
# ============================
# Build e Setuptools
# ============================
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
# Informa ao setuptools para encontrar os pacotes dentro da pasta 'src'.
# Essencial para a estrutura de layout com 'src/'.
where = ["src"]
[tool.setuptools]
# Mapeia o diretório raiz de pacotes para 'src'.
package-dir = { "" = "src" }