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

Refactor logging functions to use %s formatting instead of f-strings #3822

Merged

Conversation

StarKBhaviN
Copy link
Contributor

@StarKBhaviN StarKBhaviN commented Nov 19, 2023

Fixes #3820

You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments.
If logging-not-lazy is disabled then you can use % formatting as normal.

Copy link
Member

@suhaibmujahid suhaibmujahid left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, @StarKBhaviN! Could you please fix the failing tests?

Using pre-commit will help in fixing the code style errors: https://github.com/mozilla/bugbug#auto-formatting

Copy link
Member

@suhaibmujahid suhaibmujahid left a comment

Choose a reason for hiding this comment

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

Thank you, @StarKBhaviN! Could you please take care of the following:

  • Drop unrelated changes
  • Link the PR to the issue that it is fixing (in the PR description1)
  • Edit the PR title to clarify that this is related to logging

Footnotes

  1. https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue

.flake8 Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
bugbug/labels/regression_bug_nobug.csv Outdated Show resolved Hide resolved
http_service/.dockerignore Outdated Show resolved Hide resolved
scripts/regressor_finder.py Outdated Show resolved Hide resolved
scripts/trainer_extract_args.py Outdated Show resolved Hide resolved
tests/fixtures/bug_features/nightly_uplift.json Outdated Show resolved Hide resolved
tests/fixtures/bugs.json Outdated Show resolved Hide resolved
bugbug/models/regressor.py Outdated Show resolved Hide resolved
- Dropped all unrelated changes.
- Bug fixes as mentioned
@StarKBhaviN StarKBhaviN changed the title Used % formatting in each fString statement. Comply with logging-fstring-interpolation / W1203 Nov 20, 2023
@suhaibmujahid suhaibmujahid linked an issue Nov 20, 2023 that may be closed by this pull request
@StarKBhaviN

This comment was marked as off-topic.

@jpangas

This comment was marked as off-topic.

@StarKBhaviN
Copy link
Contributor Author

image
Still getting same error after creating virtual env and reinstalling dependencies

@jpangas

This comment was marked as off-topic.

@suhaibmujahid

This comment was marked as off-topic.

- Reverted all unwanted changes.
- Issue resolved.
@StarKBhaviN

This comment was marked as off-topic.

@suhaibmujahid
Copy link
Member

suhaibmujahid commented Nov 22, 2023

bugbug lint is failing in codespell

Because the PR still changes the .pre-commit-config.yaml file. All unrelated changes should be dropped. Please just keep the changes related to the logging statements mentioned in the issue.

Copy link
Member

@suhaibmujahid suhaibmujahid left a comment

Choose a reason for hiding this comment

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

Thank you @StarKBhaviN! The changes to the following files are not related to this PR. Please revert the changes:

  • .flake8
  • bugbug/labels/regression_bug_nobug.csv
  • http_service/.dockerignore
  • tests/fixtures/bug_features/nightly_uplift.json
  • tests/fixtures/bugs.json

scripts/commit_classifier.py Outdated Show resolved Hide resolved
scripts/commit_classifier.py Outdated Show resolved Hide resolved
scripts/maintenance_effectiveness_indicator.py Outdated Show resolved Hide resolved
scripts/regressor_finder.py Outdated Show resolved Hide resolved
@suhaibmujahid suhaibmujahid self-assigned this Nov 24, 2023
Copy link
Member

@suhaibmujahid suhaibmujahid left a comment

Choose a reason for hiding this comment

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

Please rename the PR to something more descriptive (e.g., “Use %s formatting instead of f-string in logging functions”). Also, could you please link to the issue in the PR description?1

Footnotes

  1. https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue

@StarKBhaviN StarKBhaviN changed the title Comply with logging-fstring-interpolation / W1203 Refactor logging functions to use %s formatting instead of f-strings Nov 24, 2023
@StarKBhaviN StarKBhaviN changed the title Refactor logging functions to use %s formatting instead of f-strings Refactor logging functions to use %s formatting instead of f-strings. Fixes #3820 Nov 24, 2023
@StarKBhaviN StarKBhaviN changed the title Refactor logging functions to use %s formatting instead of f-strings. Fixes #3820 Fixes #3820 : Refactor logging functions to use %s formatting instead of f-strings. Nov 24, 2023
@suhaibmujahid suhaibmujahid changed the title Fixes #3820 : Refactor logging functions to use %s formatting instead of f-strings. Refactor logging functions to use %s formatting instead of f-strings Nov 24, 2023
Copy link
Member

@suhaibmujahid suhaibmujahid left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you, @StarKBhaviN!

@suhaibmujahid suhaibmujahid merged commit 7d85140 into mozilla:master Nov 24, 2023
6 checks passed
@StarKBhaviN StarKBhaviN deleted the fix/logging-fstring-interpolation branch November 24, 2023 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comply with logging-fstring-interpolation / W1203
3 participants