Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: Add Ruff print rules to API (T20) #1107

Merged
merged 1 commit into from
Jan 24, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ def execute(self, owner, current_owner):
owner.add_admin(current_owner)
return isAdmin or (current_owner.ownerid in admins)
except Exception as error:
print("Error Calling Admin Provider " + repr(error))
print("Error Calling Admin Provider " + repr(error)) # noqa: T201
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ignored removing all the prints for the django commands

return False
7 changes: 3 additions & 4 deletions core/management/commands/check_for_migration_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ def handle(self, *args, **options):
for prefix, grouped_migrations in migrations_by_prefix.items():
if len(grouped_migrations) > 1:
conflicts_found = True
print(
print( # noqa: T201
f"Conflict found in migrations for {app.name} with prefix {prefix}:"
)
for grouped_migration in grouped_migrations:
print(grouped_migration)
print()
print(grouped_migration) # noqa: T201
# It's expected to not find migration folders for Django/3rd party apps
except FileNotFoundError:
pass

if conflicts_found:
raise Exception("Found conflicts in migrations.")
else:
print("No conflicts found!")
print("No conflicts found!") # noqa: T201
6 changes: 3 additions & 3 deletions core/management/commands/delete_rate_limit_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
for key in redis.scan_iter(path):
# -1 means the key has no expiry
if redis.ttl(key) == -1:
print(f"Deleting key: {key.decode('utf-8')}")
print(f"Deleting key: {key.decode('utf-8')}") # noqa: T201
redis.delete(key)
except Exception as e:
print("Error occurred when deleting redis keys")
print(e)
print("Error occurred when deleting redis keys") # noqa: T201
print(e) # noqa: T201

Check warning on line 28 in core/management/commands/delete_rate_limit_keys.py

View check run for this annotation

Codecov Notifications / codecov/patch

core/management/commands/delete_rate_limit_keys.py#L27-L28

Added lines #L27 - L28 were not covered by tests
9 changes: 3 additions & 6 deletions core/management/commands/update_gitlab_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
)

for repo in repos:
print("repoid:", repo.pk)

user = get_bot_user(repo)
if user is None:
print("no bot user")
continue

webhook_secret = str(uuid.uuid4())
Expand Down Expand Up @@ -63,7 +60,7 @@
repo.webhook_secret = webhook_secret
repo.save()
except TorngitClientError as e:
print("error making GitLab API call")
print(e)
print("error making GitLab API call") # noqa: T201
print(e) # noqa: T201

Check warning on line 64 in core/management/commands/update_gitlab_webhooks.py

View check run for this annotation

Codecov Notifications / codecov/patch

core/management/commands/update_gitlab_webhooks.py#L63-L64

Added lines #L63 - L64 were not covered by tests
except TorngitRefreshTokenFailedError:
print("refresh token failed")
print("refresh token failed") # noqa: T201

Check warning on line 66 in core/management/commands/update_gitlab_webhooks.py

View check run for this annotation

Codecov Notifications / codecov/patch

core/management/commands/update_gitlab_webhooks.py#L66

Added line #L66 was not covered by tests
1 change: 0 additions & 1 deletion graphql_api/tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def test_plan_user_count_for_enterprise_org(self, mocked_license):
}
""" % (enterprise_org.username)
data = self.gql_request(query, owner=enterprise_org)
print(data, "look here 1")
assert data["owner"]["plan"]["planUserCount"] == 5
assert data["owner"]["plan"]["hasSeatsLeft"] == False

Expand Down
8 changes: 4 additions & 4 deletions open_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@
logging.exception("failed to export all spans")
return SpanExportResult.FAILURE
except requests.HTTPError as e:
print(e)
logging.exception("HTTP server returned erroneous response")
logging.exception(

Check warning on line 144 in open_telemetry.py

View check run for this annotation

Codecov Notifications / codecov/patch

open_telemetry.py#L144

Added line #L144 was not covered by tests
"HTTP server returned erroneous response", extra=dict(error=e)
)
return SpanExportResult.FAILURE
except requests.Timeout:
logging.exception("request timed out")
return SpanExportResult.FAILURE
except Exception as e:
print(e)
logging.exception("request failed")
logging.exception("request failed", extra=dict(error=e))

Check warning on line 152 in open_telemetry.py

View check run for this annotation

Codecov Notifications / codecov/patch

open_telemetry.py#L152

Added line #L152 was not covered by tests
return SpanExportResult.FAILURE

return SpanExportResult.SUCCESS
Expand Down
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ select = [
"PERF", # perflint - performance anti-pattern rules
"PLC", # pylint - convention rules
"PLE", # pylint - error rules
"T20", # flake8-print - print statements
"W", # pycodestyle - warning rules
]
ignore = ["F405", "F403", "E501", "E712", "C408"]
Expand Down
Loading