Skip to content

Commit 464afdc

Browse files
committed
Check that no magic values are used
1 parent d547aef commit 464afdc

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

dbutils/pooled_pg.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@
117117
from . import __version__
118118
from .steady_pg import SteadyPgConnection
119119

120+
# constants for "reset" parameter
121+
RESET_ALWAYS_ROLLBACK = 1
122+
RESET_COMPLETELY = 2
123+
120124

121125
class PooledPgError(Exception):
122126
"""General PooledPg error."""
@@ -214,10 +218,10 @@ def connection(self):
214218
def cache(self, con):
215219
"""Put a connection back into the pool cache."""
216220
try:
217-
if self._reset == 2:
221+
if self._reset == RESET_COMPLETELY:
218222
con.reset() # reset the connection completely
219223
else:
220-
if self._reset or con._transaction:
224+
if self._reset == RESET_ALWAYS_ROLLBACK or con._transaction:
221225
try:
222226
con.rollback() # rollback a possible transaction
223227
except Exception:

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ line-length = 79
6666
target-version = "py37"
6767

6868
[tool.ruff.mccabe]
69-
max-complexity = 31
69+
max-complexity = 32
7070

7171
[tool.ruff.pylint]
72-
allow-magic-value-types = ["int", "str"]
73-
max-args = 12
74-
max-branches = 41
75-
max-statements = 95
72+
max-args = 15
73+
max-branches = 50
74+
max-statements = 100
7675

7776
[tool.ruff.per-file-ignores]
7877
"docs/*" = [
79-
"INP001" # allow stand-alone scripts
78+
"INP001", # allow stand-alone scripts
8079
]
8180
"tests/*" = [
82-
"S101" # allow assert statements
81+
"PLR2004", # allow magic values
82+
"S101", # allow assert statements
8383
]

0 commit comments

Comments
 (0)