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 Most F Rules to Worker #496

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@ lint.install:
echo "Installing..."
pip install -Iv ruff

# The preferred method (for now) w.r.t. fixable rules is to manually update the makefile
# with --fix and re-run 'make lint.' Since ruff is constantly adding rules this is a slight
# amount of "needed" friction imo.
lint.run:
ruff check --select F401 --select I . --fix
ruff check
ruff format

lint.check:
echo "Linting..."
ruff check
echo "Formatting..."
ruff format --check
echo "Sorting..."
ruff check --select F401 --select I .

build.requirements:
# if docker pull succeeds, we have already build this version of
Expand Down
63 changes: 63 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.12
target-version = "py312"

[lint]
# Currently only enabled for most F (Pyflakes) and I (isort) rules: https://docs.astral.sh/ruff/rules/
select = ["F", "I"]
ignore = ["F841", "F405", "F403"]

# Allow fix for all enabled rules (when `--fix`) is provided.
# The preferred method (for now) w.r.t. fixable rules is to manually update the makefile
# with --fix and re-run 'make lint'
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
4 changes: 2 additions & 2 deletions services/notification/notifiers/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def get_upgrade_message(self, comparison: Comparison) -> str:
[
f"The author of this PR, {author_username}, is not an activated member of this organization on Codecov.",
f"Please [activate this user on Codecov]({links['members_url']}) to display a detailed status check.",
f"Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.",
f"Please don't hesitate to email us at [email protected] with any questions.",
"Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.",
"Please don't hesitate to email us at [email protected] with any questions.",
]
)

Expand Down
12 changes: 6 additions & 6 deletions services/notification/notifiers/comment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ def _create_reached_upload_limit_message(self, comparison):
f"This org is currently on the free Basic Plan; which includes 250 free private repo uploads each rolling month.\
This limit has been reached and additional reports cannot be generated. For unlimited uploads,\
upgrade to our [pro plan]({links['plan_url']}).",
f"",
f"**Do you have questions or need help?** Connect with our sales team today at ` [email protected] `",
"",
"**Do you have questions or need help?** Connect with our sales team today at ` [email protected] `",
]

def _create_upgrade_message(self, comparison):
Expand All @@ -430,15 +430,15 @@ def _create_upgrade_message(self, comparison):
return [
f"The author of this PR, {author_username}, is not an activated member of this organization on Codecov.",
f"Please [activate this user on Codecov]({links['members_url_cloud']}) to display this PR comment.",
f"Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.",
f"Please don't hesitate to email us at [email protected] with any questions.",
"Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.",
"Please don't hesitate to email us at [email protected] with any questions.",
]
else:
return [
f"The author of this PR, {author_username}, is not activated in your Codecov Self-Hosted installation.",
f"Please [activate this user]({links['members_url_self_hosted']}) to display this PR comment.",
f"Coverage data is still being uploaded to Codecov Self-Hosted for the purposes of overall coverage calculations.",
f"Please contact your Codecov On-Premises installation administrator with any questions.",
"Coverage data is still being uploaded to Codecov Self-Hosted for the purposes of overall coverage calculations.",
"Please contact your Codecov On-Premises installation administrator with any questions.",
]

def _create_processing_upload_message(self):
Expand Down
5 changes: 4 additions & 1 deletion services/notification/notifiers/mixins/message/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ def _row(title, c1, c2, plus="+", minus="-", neutral=" "):
spacer = ["=" * row_w]

title = "@@%s@@" % "{text:{fill}{align}{width}}".format(
text="Coverage Diff", fill=" ", align="^", width=row_w - 4, strip=True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Strip is an unused Param here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was already fixed after rebasing 🤷

text="Coverage Diff",
fill=" ",
align="^",
width=row_w - 4,
)

table = (
Expand Down
2 changes: 1 addition & 1 deletion services/notification/notifiers/mixins/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def _apply_removals_only_behavior(
)
)
if no_added_no_unexpected_change and some_removed:
return ("success", f", passed because this change only removed code")
return ("success", ", passed because this change only removed code")
return None

async def _apply_adjust_base_behavior(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,12 @@ async def test_notify_upload_limited(
assert result.notification_successful
assert result.explanation is None
expected_message = [
f"## [Codecov](https://app.codecov.io/plan/gh/test-acc9) upload limit reached :warning:",
f"This org is currently on the free Basic Plan; which includes 250 free private repo uploads each rolling month.\
"## [Codecov](https://app.codecov.io/plan/gh/test-acc9) upload limit reached :warning:",
"This org is currently on the free Basic Plan; which includes 250 free private repo uploads each rolling month.\
This limit has been reached and additional reports cannot be generated. For unlimited uploads,\
upgrade to our [pro plan](https://app.codecov.io/plan/gh/test-acc9).",
f"",
f"**Do you have questions or need help?** Connect with our sales team today at ` [email protected] `",
"",
"**Do you have questions or need help?** Connect with our sales team today at ` [email protected] `",
]
for exp, res in zip(result.data_sent["message"], expected_message):
assert exp == res
Expand Down
Loading
Loading