Skip to content

Commit 8d719a4

Browse files
authored
Merge pull request #1216 from dbfixtures/pre-commit-updates
Various pre-commit updates
2 parents 916607d + d1c068b commit 8d719a4

File tree

14 files changed

+59
-91
lines changed

14 files changed

+59
-91
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ repos:
2222
- id: detect-private-key
2323
- id: debug-statements
2424

25-
- repo: https://github.com/psf/black-pre-commit-mirror
26-
rev: 25.9.0
27-
hooks:
28-
- id: black
29-
entry: black --config pyproject.toml .
30-
3125
- repo: https://github.com/astral-sh/ruff-pre-commit
3226
rev: v0.14.3
3327
hooks:
34-
- id: ruff
28+
- id: ruff-check
3529
args: [--fix, --exit-non-zero-on-fix, --respect-gitignore, --show-fixes]
30+
- id: ruff-format
3631

3732
- repo: https://github.com/rstcheck/rstcheck
3833
rev: v6.2.5
3934
hooks:
4035
- id: rstcheck
4136
additional_dependencies: [sphinx, toml]
4237

38+
- repo: https://github.com/fizyk/pyproject-validator
39+
rev: v0.1.0
40+
hooks:
41+
- id: check-python-version-consistency
42+
4343
- repo: local
4444
hooks:
4545
- id: pipenv

mypy.ini

Lines changed: 0 additions & 20 deletions
This file was deleted.

newsfragments/+a216cec3.misc.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Updates to pre-commit
2+
3+
Replaced black with ruff-format, Added https://github.com/fizyk/pyproject-validator,
4+
Moved mypy configuration into pyproject.toml, extended line length to 120 characters.

pyproject.toml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ testpaths = "tests"
6363
pytester_example_dir = "tests/examples"
6464
norecursedirs = "examples"
6565

66-
[tool.black]
67-
line-length = 100
68-
target-version = ['py310']
69-
include = '.*\.pyi?$'
70-
7166
[tool.ruff]
72-
line-length = 100
67+
line-length = 120
68+
target-version = 'py310'
69+
70+
[tool.ruff.lint]
7371
select = [
7472
"E", # pycodestyle
7573
"F", # pyflakes
@@ -80,6 +78,27 @@ select = [
8078
[tool.rstcheck]
8179
report_level = "warning"
8280

81+
[tool.mypy]
82+
allow_redefinition = "False"
83+
allow_untyped_globals = "False"
84+
check_untyped_defs = "True"
85+
disallow_incomplete_defs = "True"
86+
disallow_subclassing_any = "True"
87+
disallow_untyped_calls = "True"
88+
disallow_untyped_decorators = "True"
89+
disallow_untyped_defs = "True"
90+
follow_imports = "silent"
91+
ignore_missing_imports = "False"
92+
implicit_reexport = "False"
93+
no_implicit_optional = "True"
94+
pretty = "True"
95+
show_error_codes = "True"
96+
strict_equality = "True"
97+
warn_no_return = "True"
98+
warn_return_any = "True"
99+
warn_unreachable = "True"
100+
warn_unused_ignores = "True"
101+
83102
[tool.towncrier]
84103
directory = "newsfragments"
85104
single_file=true

pytest_postgresql/executor_noop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with pytest-postgresql. If not, see <http://www.gnu.org/licenses/>.
1818
"""PostgreSQL Noop executor providing connection details for postgres client."""
19+
1920
from typing import Any
2021

2122
import psycopg

pytest_postgresql/factories/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with pytest-postgresql. If not, see <http://www.gnu.org/licenses/>.
1818
"""Fixture factory for postgresql client."""
19+
1920
from typing import Callable, Iterator
2021

2122
import psycopg
@@ -50,9 +51,7 @@ def postgresql_factory(request: FixtureRequest) -> Iterator[Connection]:
5051
:param request: fixture request object
5152
:returns: postgresql client
5253
"""
53-
proc_fixture: PostgreSQLExecutor | NoopExecutor = request.getfixturevalue(
54-
process_fixture_name
55-
)
54+
proc_fixture: PostgreSQLExecutor | NoopExecutor = request.getfixturevalue(process_fixture_name)
5655
config = get_config(request)
5756

5857
pg_host = proc_fixture.host

pytest_postgresql/factories/noprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with pytest-postgresql. If not, see <http://www.gnu.org/licenses/>.
1818
"""Fixture factory for existing postgresql server."""
19+
1920
import os
2021
from pathlib import Path
2122
from typing import Callable, Iterator

pytest_postgresql/factories/process.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,14 @@ def _pg_exe(executable: str | None, config: PostgresqlConfigDict) -> str:
4343
# only replace it if executable isn't passed manually
4444
if not os.path.exists(postgresql_ctl) and executable is None:
4545
try:
46-
pg_bindir = subprocess.check_output(
47-
["pg_config", "--bindir"], universal_newlines=True
48-
).strip()
46+
pg_bindir = subprocess.check_output(["pg_config", "--bindir"], universal_newlines=True).strip()
4947
except FileNotFoundError as ex:
50-
raise ExecutableMissingException(
51-
"Could not found pg_config executable. Is it in systenm $PATH?"
52-
) from ex
48+
raise ExecutableMissingException("Could not found pg_config executable. Is it in systenm $PATH?") from ex
5349
postgresql_ctl = os.path.join(pg_bindir, "pg_ctl")
5450
return postgresql_ctl
5551

5652

57-
def _pg_port(
58-
port: PortType | None, config: PostgresqlConfigDict, excluded_ports: Iterable[int]
59-
) -> int:
53+
def _pg_port(port: PortType | None, config: PostgresqlConfigDict, excluded_ports: Iterable[int]) -> int:
6054
"""User specified port, otherwise find an unused port from config."""
6155
pg_port = get_port(port, excluded_ports) or get_port(config["port"], excluded_ports)
6256
assert pg_port is not None

pytest_postgresql/janitor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ def connect() -> Connection:
139139
port=self.port,
140140
)
141141

142-
conn = retry(
143-
connect, timeout=self._connection_timeout, possible_exception=psycopg.OperationalError
144-
)
142+
conn = retry(connect, timeout=self._connection_timeout, possible_exception=psycopg.OperationalError)
145143
conn.isolation_level = self.isolation_level
146144
# We must not run a transaction since we create a database.
147145
conn.autocommit = True

pytest_postgresql/plugin.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444

4545
def pytest_addoption(parser: Parser) -> None:
4646
"""Configure options for pytest-postgresql."""
47-
parser.addini(
48-
name="postgresql_exec", help=_help_executable, default="/usr/lib/postgresql/13/bin/pg_ctl"
49-
)
47+
parser.addini(name="postgresql_exec", help=_help_executable, default="/usr/lib/postgresql/13/bin/pg_ctl")
5048

5149
parser.addini(name="postgresql_host", help=_help_host, default="127.0.0.1")
5250

@@ -97,13 +95,9 @@ def pytest_addoption(parser: Parser) -> None:
9795

9896
parser.addoption("--postgresql-user", action="store", dest="postgresql_user", help=_help_user)
9997

100-
parser.addoption(
101-
"--postgresql-password", action="store", dest="postgresql_password", help=_help_password
102-
)
98+
parser.addoption("--postgresql-password", action="store", dest="postgresql_password", help=_help_password)
10399

104-
parser.addoption(
105-
"--postgresql-options", action="store", dest="postgresql_options", help=_help_options
106-
)
100+
parser.addoption("--postgresql-options", action="store", dest="postgresql_options", help=_help_options)
107101

108102
parser.addoption(
109103
"--postgresql-startparams",
@@ -119,9 +113,7 @@ def pytest_addoption(parser: Parser) -> None:
119113
help=_help_unixsocketdir,
120114
)
121115

122-
parser.addoption(
123-
"--postgresql-dbname", action="store", dest="postgresql_dbname", help=_help_dbname
124-
)
116+
parser.addoption("--postgresql-dbname", action="store", dest="postgresql_dbname", help=_help_dbname)
125117

126118
parser.addoption("--postgresql-load", action="append", dest="postgresql_load", help=_help_load)
127119

0 commit comments

Comments
 (0)