Skip to content

Commit

Permalink
fix or ignore print statements (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-sentry authored Jan 24, 2025
1 parent e854f50 commit 8db93ad
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 34 deletions.
6 changes: 3 additions & 3 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ indent-width = 4
target-version = "py312"

[lint]
# Currently only enabled for F (Pyflakes), I (isort), E,W (pycodestyle:Error/Warning), PLC/PLE/PLW (Pylint:Convention/Error/Warning)
# and PERF (Perflint) rules: https://docs.astral.sh/ruff/rules/
select = ["F", "I", "E", "W", "PLC", "PLE", "PLW", "PERF"]
# Currently only enabled for F (Pyflakes), I (isort), E,W (pycodestyle:Error/Warning), PLC/PLE/PLW (Pylint:Convention/Error/Warning),
# PERF (Perflint), and T20 (Flake8-print) rules: https://docs.astral.sh/ruff/rules/
select = ["F", "I", "E", "W", "PLC", "PLE", "PLW", "PERF", "T20"]
ignore = ["F403", "F405", "E501", "E712"]

# Allow fix for all enabled rules (when `--fix`) is provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Migration(migrations.Migration):
]

def populate_test_instances(apps, schema_editor):
print("Not running due to performance")
print("Not running due to performance") # noqa: T201
return
TestInstance = apps.get_model("reports", "TestInstance")

Expand Down
2 changes: 1 addition & 1 deletion shared/license/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def startup_license_logging():

# printing the message in a single statement so the lines won't get split up
# among all the other messages during startup
print(*statements_to_print, sep="\n")
print(*statements_to_print, sep="\n") # noqa: T201
2 changes: 1 addition & 1 deletion shared/storage/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def delete_files(self, bucket_name: str, paths: list[str]) -> list[bool]:
for del_err in self.minio_client.remove_objects(
bucket_name, [DeleteObject(path) for path in paths]
):
print("Deletion error: {}".format(del_err))
print("Deletion error: {}".format(del_err)) # noqa: T201
return [True] * len(paths)
except MinioException:
raise
Expand Down
2 changes: 1 addition & 1 deletion shared/storage/new_minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def delete_files(self, bucket_name, urls=[]):
for del_err in self.minio_client.remove_objects(
bucket_name, [DeleteObject(url) for url in urls]
):
print("Deletion error: {}".format(del_err))
print("Deletion error: {}".format(del_err)) # noqa: T201
return [True] * len(urls)
except MinioException:
raise
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/test_bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ async def test_get_compare(self, valid_handler, codecov_vcr):
"commits": [{"commitid": "b92edba"}, {"commitid": "6ae5f17"}],
}
res = await valid_handler.get_compare(base, head)
print(res)
assert sorted(list(res.keys())) == sorted(list(expected_result.keys()))
assert res == expected_result

Expand Down Expand Up @@ -1043,7 +1042,6 @@ async def test_list_repos_no_username(self, valid_handler, codecov_vcr):
}
]
res = await valid_handler.list_repos()
print(res)
assert sorted(res, key=lambda x: x["repo"]["service_id"]) == sorted(
expected_result, key=lambda x: x["repo"]["service_id"]
)
Expand Down Expand Up @@ -1089,7 +1087,6 @@ async def test_list_teams(self, valid_handler, codecov_vcr):
},
]
res = await valid_handler.list_teams()
print(res)
assert res == expected_result

@pytest.mark.asyncio
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ async def test_get_commit_diff(self, valid_handler, codecov_vcr):
res = await valid_handler.get_commit_diff(
"c739768fcac68144a3a6d82305b9c4106934d31a"
)
print(list(res.keys()))
assert res == expected_result

@pytest.mark.asyncio
Expand Down Expand Up @@ -364,7 +363,6 @@ async def test_set_commit_status(self, valid_handler, codecov_vcr):
@pytest.mark.asyncio
async def test_get_branches(self, valid_handler, codecov_vcr):
branches = sorted(await valid_handler.get_branches())
print(branches)
assert list(map(lambda a: a[0], branches)) == ["main", "other-branch"]

@pytest.mark.asyncio
Expand All @@ -374,7 +372,6 @@ async def test_get_branch(self, valid_handler, codecov_vcr):
"sha": "0fc784af11c401449e56b24a174bae7b9af86c98",
}
branch = await valid_handler.get_branch("main")
print(branch)
assert branch == expected_result

@pytest.mark.asyncio
Expand Down Expand Up @@ -507,7 +504,6 @@ async def test_get_compare(self, valid_handler, codecov_vcr):
],
}
res = await valid_handler.get_compare(base, head)
print(res)
assert sorted(list(res.keys())) == sorted(list(expected_result.keys()))
for key in res:
assert res[key] == expected_result[key]
Expand Down
1 change: 0 additions & 1 deletion tests/unit/reports/samples/test_filtered.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,6 @@ def test_apply_diff_not_saving(self, sample_report):
}

def test_network(self, sample_report):
print(list(sample_report.filter(paths=[".*go"]).network))
assert list(sample_report.filter(paths=[".*go"]).network) == [
(
"file_1.go",
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/reports/test_carryforward.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dataclasses
import pprint
from json import loads

import pytest
Expand Down Expand Up @@ -400,7 +399,6 @@ def test_generate_carryforward_report_one_file_not_covered(self, sample_report):
assert res.files == ["file_1.go"]
readable_report = self.convert_report_to_better_readable(res)

pprint.pprint(readable_report)
expected_result = {
"archive": {
"file_1.go": [
Expand Down Expand Up @@ -473,7 +471,6 @@ def test_generate_carryforward_report_session_extras(self, sample_report):
assert res.files == ["file_1.go"]
readable_report = self.convert_report_to_better_readable(res)

pprint.pprint(readable_report)
expected_result = {
"archive": {
"file_1.go": [
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/reports/test_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def test_run_comparison_using_rust(sample_rust_report):
}
}
k = run_comparison_using_rust(base_report, head_report, diff)
print(k)
assert k == {
"files": [
{
Expand Down Expand Up @@ -154,7 +153,6 @@ def test_get_changes_using_rust(sample_rust_report):
}
}
k = get_changes_using_rust(base_report, head_report, diff)
print(k)
assert k == [
Change(
path="tests/__init__.py",
Expand Down Expand Up @@ -532,5 +530,4 @@ def test_rustify_diff_new_file(self):
[((43, 7, 43, 7), [" ", " ", " ", "-", "+", " ", " ", " "])],
),
}
print(rustify_diff(user_input))
assert rustify_diff(user_input) == expected_result
2 changes: 0 additions & 2 deletions tests/unit/reports/test_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,8 +1887,6 @@ def test_delete_labels(self, sample_with_labels_report):
if line.datapoints:
for dp in line.datapoints:
assert dp.sessionid != 0 or 3 not in dp.label_ids
print(sample_with_labels_report)
print(sample_with_labels_report._files)
res = self.convert_report_to_better_readable(sample_with_labels_report)
expected_result = {
"totals": {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/reports/test_readonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ def test_create_from_report(self, sample_report, mocker, report_header):

def test_get_file_totals(self, sample_report, mocker):
r = ReadOnlyReport.create_from_report(sample_report)
print(sample_report._files)
print(r)
assert r.get_file_totals("location/file_1.py") == ReportTotals(
files=0,
lines=2,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/reports/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def test_networkfile_as_tuple(self):
),
diff_totals=None,
)
print(network_file.astuple())
assert network_file.astuple() == (
(0, 0, -2, 1, 0, -23.333330000000004, 0, 0, 0, 0, 0, 0, 0),
None,
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/torngit/test_github_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,11 @@ async def test_make_http_call_change_host(self, mocker, mock_configuration):
await gl.make_http_call(client, method, url, **query_params)
assert client.request.call_count == 1
args, kwargs = client.request.call_args
print(args)
print(kwargs)
assert kwargs.get("headers") is not None
assert kwargs.get("headers").get("Host") == "ghe.com"
assert len(args) == 2
built_url = args[1]
parsed_url = urlparse(built_url)
print(parsed_url)
assert parsed_url.scheme == "https"
assert parsed_url.netloc == mock_host
assert parsed_url.path == "/random_url"
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/torngit/test_gitlab_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def test_redirect_uri(self, mocker):
assert gle.redirect_uri == "https://codecov.io/login/gle"

def custom_config(*args, **kwargs):
print(args)
if args == ("gitlab_enterprise", "redirect_uri"):
return "https://custom_redirect.com"
if args == ("setup", "codecov_url"):
Expand All @@ -26,7 +25,6 @@ def custom_config(*args, **kwargs):
)

def custom_config(*args, **kwargs):
print(args)
if args == ("gitlab", "redirect_uri"):
return None
if args == ("setup", "codecov_url"):
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/validation/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def test_translate_glob_to_regex(self):
re.compile(translate_glob_to_regex("**/test*.ts")).match("src/src2/test.ts")
is not None
)
print(f'"a/*/*b*.ts" => {translate_glob_to_regex("a/*/*b*.ts")}')
assert (
re.compile(translate_glob_to_regex("a/*/*b*.ts")).match("a/folder/b.ts")
is not None
Expand All @@ -285,7 +284,6 @@ def test_translate_glob_to_regex(self):
)
is None
)
print(f'"a/**/*b*.ts" => {translate_glob_to_regex("a/**/*b*.ts")}')
assert (
re.compile(translate_glob_to_regex("a/**/*b*.ts")).match("a/folder/b.ts")
is not None
Expand Down
1 change: 0 additions & 1 deletion tests/unit/validation/test_install_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ def test_validate_sample_production_config(mocker):
}
mock_warning = mocker.patch.object(install_log, "warning")
res = validate_install_configuration(user_input)
print(mock_warning.call_args)
assert mock_warning.call_count == 0
assert res["site"] == expected_result["site"]
assert res == expected_result
Expand Down

0 comments on commit 8db93ad

Please sign in to comment.