Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ isort.lines-after-imports = 2

[dependency-groups]
dev = [
"coverage<=7.14.3",
"docker<=7.1.0",
"pre-commit<=4.6.0",
"coverage<=7.15.2",
"docker<=7.2.0",
"pre-commit<=4.6.1",
"pytest<=9.1.1",
"ruff<=0.15.13",
"ruff<=0.16.0",
]
8 changes: 4 additions & 4 deletions requirements.uvmirror
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ charset-normalizer==3.4.9
# via requests
colorama==0.4.6 ; sys_platform == 'win32'
# via pytest
coverage==7.14.3
coverage==7.15.2
distlib==0.4.3
# via virtualenv
docker==7.1.0
docker==7.2.0
filelock==3.29.7
# via
# python-discovery
Expand All @@ -32,7 +32,7 @@ platformdirs==4.10.0
# virtualenv
pluggy==1.6.0
# via pytest
pre-commit==4.6.0
pre-commit==4.6.1
pygments==2.20.0
# via pytest
pymssql==2.3.13
Expand All @@ -46,7 +46,7 @@ pyyaml==6.0.3
# via pre-commit
requests==2.34.2
# via docker
ruff==0.15.13
ruff==0.16.0
sqlglot==30.12.0
# via sqlrunner
structlog==26.1.0
Expand Down
10 changes: 5 additions & 5 deletions sqlrunner/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def are_t1oos_handled(sql_query):
# The word boundary (\b) is necessary because PatientsWithTypeOneDissent
# is a substring of AllowedPatientsWithTypeOneDissent.
return True
if re.search(f"--.*{OLD_T1OOS_TABLE}", sql_query):
if re.search(f"--.*{OLD_T1OOS_TABLE}", sql_query): # noqa: SIM103
# If OLD_T1OOS_TABLE is referenced in a comment in the query, then the query
# is safe to run. (It would be unnecessary faff to change existing queries
# that reference the old table namein a comment to explain why T1OO data
Expand Down Expand Up @@ -115,9 +115,9 @@ def write_results(results, f_path):
if f_path is not None:
kwargs = {"newline": "", "encoding": "utf-8"}
if f_path.suffixes == [".csv", ".gz"]:
context = gzip.open(f_path, "wt", compresslevel=6, **kwargs)
context = gzip.open(f_path, "wt", compresslevel=6, **kwargs) # noqa: SIM115
else:
context = open(f_path, "w", **kwargs)
context = open(f_path, "w", **kwargs) # noqa: SIM115
else:
context = contextlib.nullcontext(sys.stdout)

Expand All @@ -132,9 +132,9 @@ def write_results(results, f_path):
def read_dummy_data_file(f_path):
kwargs = {"newline": "", "encoding": "utf-8"}
if f_path.suffixes == [".csv", ".gz"]:
context = gzip.open(f_path, "rt", **kwargs)
context = gzip.open(f_path, "rt", **kwargs) # noqa: SIM115
else:
context = open(f_path, **kwargs)
context = open(f_path, **kwargs) # noqa: SIM115

with context as f:
yield from csv.DictReader(f)
2 changes: 1 addition & 1 deletion tests/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def wait_for_database(database, timeout=10):
break
except pymssql.OperationalError as e: # pragma: no cover
if time.time() > limit:
raise Exception(
raise Exception( # noqa: TRY002
f"Failed to connect to database after {timeout} seconds"
) from e
time.sleep(1)
Expand Down
2 changes: 1 addition & 1 deletion tests/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_mapped_port_for_host(self, name, container_port):
def get_container_ip(self, name):
container = self.get_container(name)
networks = container.attrs["NetworkSettings"]["Networks"].values()
return list(networks)[0]["IPAddress"]
return next(iter(networks))["IPAddress"]

def run_bg(self, name, image, **kwargs): # pragma: no cover
return self._run(name=name, image=image, detach=True, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def test_write_results_compressed(output_path):
f_path = output_path / "results.csv.gz"
results = [{"id": 1}, {"id": 2}]
main.write_results(iter(results), f_path)
assert gzip.open(f_path, "rt").read() == "id\n1\n2\n"
with gzip.open(f_path, "rt") as f:
assert f.read() == "id\n1\n2\n"


@pytest.mark.parametrize(
Expand Down
Loading