chore: upgrade Ruff configuration and reformat codebase#861
Open
chore: upgrade Ruff configuration and reformat codebase#861
Conversation
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
used ruff (pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations, like unused imports. - isort-compatible import sorting. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…ormat. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…ring join. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
….keys()`. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…ead of `try`-`except`-`pass`. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…aders.get(<index>, None)`. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…le contexts instead of nested `with` statements. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…sted `if` statements. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…directly. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…e`-block. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
…se True`. Used Ruff (vscode and pre-commit) to: - Black-compatible code formatting. - fix all auto-fixable violations. - isort-compatible import sorting. - flake8-simplify manual fixes. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
- Deleted `src/instana/util/gunicorn.py` since the code is duplicated in `running_in_gunicorn()` function from `src/instana/log.py`. - Adapted code to import `running_in_gunicorn()` from `src/instana/log.py`. - Add tests for `running_in_gunicorn()` to increase the coverage on new code. Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
|
GSVarsha
reviewed
Apr 9, 2026
| if tracing_disable_config := config["tracing"].get("disable", None): | ||
| return parse_span_disabling(tracing_disable_config) | ||
| if "tracing" in config and ( | ||
| tracing_disable_config := config["tracing"].get("disable", None) |
Contributor
There was a problem hiding this comment.
Suggested change
| tracing_disable_config := config["tracing"].get("disable", None) | |
| tracing_disable_config := config["tracing"].get("disable") |
Member
Author
GSVarsha
reviewed
Apr 9, 2026
Comment on lines
+58
to
+68
| return bool( | ||
| rule_value == "*" | ||
| or match_type == "strict" | ||
| and span_value == rule_value | ||
| or match_type == "contains" | ||
| and rule_value in span_value | ||
| or match_type == "startswith" | ||
| and span_value.startswith(rule_value) | ||
| or match_type == "endswith" | ||
| and span_value.endswith(rule_value) | ||
| ) |
Contributor
There was a problem hiding this comment.
Just a slight adjustment for better readability.
Also I think we don't need the bool() wrapper here, as all those comparison operators already return boolean values.
Suggested change
| return bool( | |
| rule_value == "*" | |
| or match_type == "strict" | |
| and span_value == rule_value | |
| or match_type == "contains" | |
| and rule_value in span_value | |
| or match_type == "startswith" | |
| and span_value.startswith(rule_value) | |
| or match_type == "endswith" | |
| and span_value.endswith(rule_value) | |
| ) | |
| return ( | |
| rule_value == "*" or | |
| (match_type == "strict" and span_value == rule_value) or | |
| (match_type == "contains" and rule_value in span_value) or | |
| (match_type == "startswith" and span_value.startswith(rule_value)) or | |
| (match_type == "endswith" and span_value.endswith(rule_value)) | |
| ) |
Member
Author
There was a problem hiding this comment.
I'll try to apply your suggestion, but probably this will be re-formatted back to the original by Ruff when running the pre-commit rule. Let's see.
GSVarsha
reviewed
Apr 9, 2026
| import uvicorn | ||
| from ...helpers import testenv | ||
| from instana.log import logger | ||
| from instana.log import logger as logger |
Member
Author
There was a problem hiding this comment.
I don't think so. Will remove this line
GSVarsha
reviewed
Apr 9, 2026
Comment on lines
+7
to
+10
|
|
||
| from ....log import logger | ||
| from ..base import BaseHelper | ||
| from ....util import DictionaryOfStan | ||
| from ..base import BaseHelper |
Contributor
There was a problem hiding this comment.
Can we change these relative imports to absolute imports?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This PR modernizes the repository’s Ruff setup and applies the resulting formatting and lint cleanup across the codebase and tests.
.pre-commit-config.yamlv0.7.0tov0.15.9rufftoruff-checkpyproject.tomlkey in dictinstead ofkey in dict.keys()src/instana/util/gunicorn.pysince the code is duplicated inrunning_in_gunicorn()function fromsrc/instana/log.py.running_in_gunicorn()fromsrc/instana/log.py.running_in_gunicorn()to increase the coverage on new code.