Skip to content

Commit b965967

Browse files
authored
fix: correctly check for env variables (#47)
1 parent bf0e5ad commit b965967

File tree

4 files changed

+189
-57
lines changed

4 files changed

+189
-57
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919

2020
# Ruff replaces black, flake8, autoflake and isort
2121
- repo: https://github.com/charliermarsh/ruff-pre-commit
22-
rev: "v0.4.5" # make sure this is always consistent with hatch configs
22+
rev: "v0.5.6" # make sure this is always consistent with hatch configs
2323
hooks:
2424
- id: ruff
2525
args: [--config, ./pyproject.toml]

pyproject.toml

Lines changed: 181 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212
name = "pytest-databases"
1313
readme = "README.md"
1414
requires-python = ">=3.8"
15-
version = "0.7.0"
15+
version = "0.7.1"
1616
#
1717
authors = [{ name = "Cody Fincher", email = "cody.fincher@gmail.com" }]
1818
keywords = [
@@ -55,53 +55,17 @@ Source = "https://github.com/litestar-org/pytest-databases"
5555
azure-storage = ["azure-storage-blob"]
5656
bigquery = ["google-cloud-bigquery"]
5757
cockroachdb = ["psycopg"]
58-
docs = [
59-
"sphinx>=7.1.2",
60-
"sphinx-autobuild>=2021.3.14",
61-
"sphinx-copybutton>=0.5.2",
62-
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git",
63-
"sphinx-click>=5.0.1",
64-
"sphinx-toolbox>=3.5.0",
65-
"sphinx-design>=0.5.0",
66-
"sphinxcontrib-mermaid>=0.9.2",
67-
"auto-pytabs[sphinx]>=0.4.0",
68-
]
6958
dragonfly = ["redis"]
7059
elasticsearch7 = ["elasticsearch7[async]"]
7160
elasticsearch8 = ["elasticsearch8[async]"]
7261
keydb = ["redis"]
73-
lint = [
74-
"mypy",
75-
"ruff",
76-
"pylint",
77-
"pre-commit",
78-
"types-click",
79-
"types-six",
80-
"types-decorator",
81-
"types-pyyaml",
82-
"asyncpg-stubs",
83-
"types-docutils",
84-
"types-redis",
85-
]
8662
mssql = ["aioodbc"]
8763
mysql = ["asyncmy>=0.2.9"]
8864
oracle = ["oracledb"]
8965
postgres = ["asyncpg>=0.29.0"]
9066
redis = ["redis"]
9167
spanner = ["google-cloud-spanner"]
9268
sqlite = ["aiosqlite"]
93-
tests = [
94-
"anyio",
95-
"coverage[toml]>=6.2",
96-
"coverage[toml]>=6.2",
97-
"pytest",
98-
"pytest-cov",
99-
"pytest-mock",
100-
"pytest-vcr",
101-
"pytest-sugar",
102-
"pytest-click",
103-
"pytest-xdist",
104-
]
10569

10670

10771
######################
@@ -120,13 +84,82 @@ allow-direct-references = true
12084

12185
# Default environment with production dependencies
12286
[tool.hatch.envs.default]
87+
extra-dependencies = [
88+
# tests
89+
"anyio",
90+
"coverage[toml]>=6.2",
91+
"coverage[toml]>=6.2",
92+
"pytest",
93+
"pytest-cov",
94+
"pytest-mock",
95+
"pytest-vcr",
96+
"pytest-sugar",
97+
"pytest-click",
98+
"pytest-xdist",
99+
# lint
100+
"mypy",
101+
"ruff",
102+
"pylint",
103+
"pre-commit",
104+
"types-click",
105+
"types-six",
106+
"types-decorator",
107+
"types-pyyaml",
108+
"asyncpg-stubs",
109+
"types-docutils",
110+
"types-redis",
111+
# docs
112+
"sphinx>=7.1.2",
113+
"sphinx-autobuild>=2021.3.14",
114+
"sphinx-copybutton>=0.5.2",
115+
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git",
116+
"sphinx-click>=5.0.1",
117+
"sphinx-toolbox>=3.5.0",
118+
"sphinx-design>=0.5.0",
119+
"sphinxcontrib-mermaid>=0.9.2",
120+
"auto-pytabs[sphinx]>=0.4.0",
121+
]
123122
installer = "uv"
124123
python = "3.12"
125124

126125

127126
# Test environment with test-only dependencies
128127
[tool.hatch.envs.test]
129-
extra-dependencies = []
128+
extra-dependencies = [
129+
# tests
130+
"anyio",
131+
"coverage[toml]>=6.2",
132+
"coverage[toml]>=6.2",
133+
"pytest",
134+
"pytest-cov",
135+
"pytest-mock",
136+
"pytest-vcr",
137+
"pytest-sugar",
138+
"pytest-click",
139+
"pytest-xdist",
140+
# lint
141+
"mypy",
142+
"ruff",
143+
"pylint",
144+
"pre-commit",
145+
"types-click",
146+
"types-six",
147+
"types-decorator",
148+
"types-pyyaml",
149+
"asyncpg-stubs",
150+
"types-docutils",
151+
"types-redis",
152+
# docs
153+
"sphinx>=7.1.2",
154+
"sphinx-autobuild>=2021.3.14",
155+
"sphinx-copybutton>=0.5.2",
156+
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git",
157+
"sphinx-click>=5.0.1",
158+
"sphinx-toolbox>=3.5.0",
159+
"sphinx-design>=0.5.0",
160+
"sphinxcontrib-mermaid>=0.9.2",
161+
"auto-pytabs[sphinx]>=0.4.0",
162+
]
130163
features = [
131164
"oracle",
132165
"mysql",
@@ -140,8 +173,6 @@ features = [
140173
"elasticsearch8",
141174
"bigquery",
142175
"azure-storage",
143-
"tests",
144-
"docs",
145176
]
146177
template = "default"
147178
type = "virtual"
@@ -163,6 +194,41 @@ no-cov = "cov --no-cov"
163194

164195
# Docs environment
165196
[tool.hatch.envs.docs]
197+
extra-dependencies = [
198+
# tests
199+
"anyio",
200+
"coverage[toml]>=6.2",
201+
"coverage[toml]>=6.2",
202+
"pytest",
203+
"pytest-cov",
204+
"pytest-mock",
205+
"pytest-vcr",
206+
"pytest-sugar",
207+
"pytest-click",
208+
"pytest-xdist",
209+
# lint
210+
"mypy",
211+
"ruff",
212+
"pylint",
213+
"pre-commit",
214+
"types-click",
215+
"types-six",
216+
"types-decorator",
217+
"types-pyyaml",
218+
"asyncpg-stubs",
219+
"types-docutils",
220+
"types-redis",
221+
# docs
222+
"sphinx>=7.1.2",
223+
"sphinx-autobuild>=2021.3.14",
224+
"sphinx-copybutton>=0.5.2",
225+
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git",
226+
"sphinx-click>=5.0.1",
227+
"sphinx-toolbox>=3.5.0",
228+
"sphinx-design>=0.5.0",
229+
"sphinxcontrib-mermaid>=0.9.2",
230+
"auto-pytabs[sphinx]>=0.4.0",
231+
]
166232
features = [
167233
"oracle",
168234
"mysql",
@@ -175,8 +241,6 @@ features = [
175241
"elasticsearch7",
176242
"elasticsearch8",
177243
"bigquery",
178-
"tests",
179-
"docs",
180244
]
181245
python = "3.11"
182246
template = "default"
@@ -195,6 +259,41 @@ validate = "linkchecker --config .linkcheckerrc --ignore-url=/reference --ignore
195259
build-check = ["build", "validate"]
196260

197261
[tool.hatch.envs.local]
262+
extra-dependencies = [
263+
# tests
264+
"anyio",
265+
"coverage[toml]>=6.2",
266+
"coverage[toml]>=6.2",
267+
"pytest",
268+
"pytest-cov",
269+
"pytest-mock",
270+
"pytest-vcr",
271+
"pytest-sugar",
272+
"pytest-click",
273+
"pytest-xdist",
274+
# lint
275+
"mypy",
276+
"ruff",
277+
"pylint",
278+
"pre-commit",
279+
"types-click",
280+
"types-six",
281+
"types-decorator",
282+
"types-pyyaml",
283+
"asyncpg-stubs",
284+
"types-docutils",
285+
"types-redis",
286+
# docs
287+
"sphinx>=7.1.2",
288+
"sphinx-autobuild>=2021.3.14",
289+
"sphinx-copybutton>=0.5.2",
290+
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git",
291+
"sphinx-click>=5.0.1",
292+
"sphinx-toolbox>=3.5.0",
293+
"sphinx-design>=0.5.0",
294+
"sphinxcontrib-mermaid>=0.9.2",
295+
"auto-pytabs[sphinx]>=0.4.0",
296+
]
198297
features = [
199298
"oracle",
200299
"mysql",
@@ -206,9 +305,6 @@ features = [
206305
"elasticsearch7",
207306
"elasticsearch8",
208307
"bigquery",
209-
"docs",
210-
"lint",
211-
"tests",
212308
]
213309
path = ".venv/"
214310
python = "3.11"
@@ -218,9 +314,42 @@ type = "virtual"
218314

219315
# Lint environment
220316
[tool.hatch.envs.lint]
221-
detached = true
222-
features = ["lint"]
223-
python = "3.11"
317+
extra-dependencies = [
318+
# tests
319+
"anyio",
320+
"coverage[toml]>=6.2",
321+
"coverage[toml]>=6.2",
322+
"pytest",
323+
"pytest-cov",
324+
"pytest-mock",
325+
"pytest-vcr",
326+
"pytest-sugar",
327+
"pytest-click",
328+
"pytest-xdist",
329+
# lint
330+
"mypy",
331+
"ruff",
332+
"pylint",
333+
"pre-commit",
334+
"types-click",
335+
"types-six",
336+
"types-decorator",
337+
"types-pyyaml",
338+
"asyncpg-stubs",
339+
"types-docutils",
340+
"types-redis",
341+
# docs
342+
"sphinx>=7.1.2",
343+
"sphinx-autobuild>=2021.3.14",
344+
"sphinx-copybutton>=0.5.2",
345+
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git",
346+
"sphinx-click>=5.0.1",
347+
"sphinx-toolbox>=3.5.0",
348+
"sphinx-design>=0.5.0",
349+
"sphinxcontrib-mermaid>=0.9.2",
350+
"auto-pytabs[sphinx]>=0.4.0",
351+
]
352+
python = "3.12"
224353
type = "virtual"
225354

226355
[tool.hatch.envs.lint.scripts]
@@ -456,6 +585,10 @@ lint.ignore = [
456585
"COM812",
457586
"PLR0917",
458587
"CPY001", # copywrite check
588+
"DOC201", # `return` is not documented in docstring
589+
"DOC501", # Raised exception missing from docstring
590+
"DOC502", # Raised exception missing from docstring
591+
"A005", # module shadows builtin
459592
]
460593
lint.select = ["ALL"]
461594
# Allow unused variables when underscore-prefixed.

src/pytest_databases/docker/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@
44
import os
55
import re
66
import subprocess # noqa: S404
7-
import sys
87
import timeit
98
from typing import TYPE_CHECKING, Any, Callable, Iterable
109

11-
import pytest
12-
1310
from pytest_databases.helpers import simple_string_hash, wrap_sync
1411

1512
if TYPE_CHECKING:
1613
from collections.abc import Awaitable, Generator
1714
from pathlib import Path
1815

16+
TRUE_VALUES = {"True", "true", "1", "yes", "Y", "T"}
17+
1918

2019
async def wait_until_responsive(
2120
check: Callable[..., Awaitable],
22-
timeout: float,
21+
timeout: float, # noqa: ASYNC109
2322
pause: float,
2423
**kwargs: Any,
2524
) -> None:
@@ -43,8 +42,8 @@ async def wait_until_responsive(
4342
raise RuntimeError(msg)
4443

4544

46-
SKIP_DOCKER_COMPOSE: bool = bool(os.environ.get("SKIP_DOCKER_COMPOSE", False))
47-
USE_LEGACY_DOCKER_COMPOSE: bool = bool(os.environ.get("USE_LEGACY_DOCKER_COMPOSE", False))
45+
SKIP_DOCKER_COMPOSE: bool = os.environ.get("SKIP_DOCKER_COMPOSE", "False") in TRUE_VALUES
46+
USE_LEGACY_DOCKER_COMPOSE: bool = os.environ.get("USE_LEGACY_DOCKER_COMPOSE", "False") in TRUE_VALUES
4847
COMPOSE_PROJECT_NAME: str = f"pytest-databases-{simple_string_hash(__file__)}"
4948

5049

@@ -88,7 +87,7 @@ async def start(
8887
docker_compose_files: list[Path],
8988
*,
9089
check: Callable[..., Any],
91-
timeout: float = 30,
90+
timeout: float = 30, # noqa: ASYNC109
9291
pause: float = 0.1,
9392
**kwargs: Any,
9493
) -> None:

src/pytest_databases/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, cm: AbstractContextManager[T]) -> None:
2222
self._cm = cm
2323

2424
async def __aenter__(self) -> T:
25-
return self._cm.__enter__()
25+
return self._cm.__enter__() # type: ignore[return-value]
2626

2727
async def __aexit__(
2828
self,

0 commit comments

Comments
 (0)