-
Notifications
You must be signed in to change notification settings - Fork 362
Deprecation Warnings #6256
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
base: master
Are you sure you want to change the base?
Deprecation Warnings #6256
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -508,3 +508,9 @@ def to_text(data, encoding=ENCODING, errors="strict"): | |
| if not isinstance(data, str): | ||
| return str(data) | ||
| return data | ||
|
|
||
|
|
||
| # pylint: disable=wrong-import-position | ||
| from avocado.utils.deprecation import log_deprecation | ||
|
|
||
| log_deprecation.warning("astring") | ||
|
Comment on lines
+513
to
+516
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a custom Using
Consider replacing this with a standard # at the top of avocado/utils/astring.py
import warnings
warnings.warn(
"The 'astring' utility is deprecated. It has been moved to the AAutils "
"project and will be removed after the next LTS release. For more "
"information, please see: https://github.com/avocado-framework/aautils",
DeprecationWarning,
stacklevel=2
)If the custom References
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -894,3 +894,9 @@ def connect(self): | |
|
|
||
| if self._extended_mode: | ||
| self.set_extended_mode() | ||
|
|
||
|
|
||
| # pylint: disable=wrong-import-position | ||
| from avocado.utils.deprecation import log_deprecation | ||
|
|
||
| log_deprecation.warning("gdb") | ||
|
Comment on lines
+899
to
+902
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a custom Using
Consider replacing this with a standard # at the top of avocado/utils/gdb.py
import warnings
warnings.warn(
"The 'gdb' utility is deprecated. It has been moved to the AAutils "
"project and will be removed after the next LTS release. For more "
"information, please see: https://github.com/avocado-framework/aautils",
DeprecationWarning,
stacklevel=2
)If the custom References
Comment on lines
+899
to
+902
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify the deprecation warning implementation and check if warnings are actually emitted
echo "=== Checking log_deprecation implementation ==="
if [ -f avocado/utils/deprecation.py ]; then
cat avocado/utils/deprecation.py
else
echo "File not found: avocado/utils/deprecation.py"
fi
echo -e "\n=== Searching for log_deprecation usage patterns ==="
rg -n "log_deprecation" --type=py -A 3 -B 1 | head -100
echo -e "\n=== Searching for deprecation warnings module imports ==="
rg -n "import warnings" --type=py | head -20Repository: avocado-framework/avocado Length of output: 6415 🏁 Script executed: #!/bin/bash
echo "=== Searching for all flush() calls ==="
rg -n "\.flush\(\)" --type=py -B 2 -A 2
echo -e "\n=== Checking if there are tests for deprecation warnings ==="
fd -t f -n "*test*deprecation*" --type f
rg -n "log_deprecation\|LogDeprecation" -t py testRepository: avocado-framework/avocado Length of output: 8482 🏁 Script executed: #!/bin/bash
echo "=== Finding all log_deprecation.flush() calls ==="
rg "log_deprecation\.flush" --type=py -B 5 -A 5
echo -e "\n=== Checking where/when log_deprecation warnings would be emitted ==="
rg "log_deprecation" --type=py | grep -E "(flush|warning)" | head -40
echo -e "\n=== Checking if there are integration tests that verify deprecation warnings ==="
fd test -type f | xargs rg "deprecation" -l 2>/dev/null | head -10Repository: avocado-framework/avocado Length of output: 2610 🏁 Script executed: #!/bin/bash
echo "=== Checking for tests related to deprecation ==="
find . -type f -name "*.py" -path "*test*" | xargs rg "log_deprecation\|LogDeprecation" 2>/dev/null
echo -e "\n=== Checking when flush would be called during test execution ==="
rg "flush" avocado/plugins/runners/avocado_instrumented.py -B 10 -A 10
echo -e "\n=== Checking if any CLI or main entry points call flush ==="
rg "log_deprecation" avocado/core --type=py
rg "log_deprecation" avocado/plugins --type=py
echo -e "\n=== Checking documentation or release notes ==="
grep -r "log_deprecation\|LogDeprecation" docs/ 2>/dev/null || echo "No documentation found"Repository: avocado-framework/avocado Length of output: 1227 🏁 Script executed: #!/bin/bash
echo "=== Checking logging configuration and where LOGGER output goes ==="
rg "LOGGER\s*=\s*logging.getLogger" avocado/utils/deprecation.py -A 5
echo -e "\n=== Checking if LOGGER.info is sufficient for warnings or if it should be LOGGER.warning ==="
rg "LOGGER\.(warning|warn)" avocado/utils/deprecation.py
echo -e "\n=== Checking logging setup in test execution ==="
rg "logging.basicConfig\|StreamHandler" avocado/core --type=py | head -20
echo -e "\n=== Verifying what happens when importing a deprecated utility outside of tests ==="
echo "The deprecation warning is only added to an internal set when imported."
echo "It is only logged when flush() is called, which happens during test execution."
echo "This means standalone imports of deprecated utilities produce no user-visible warning."Repository: avocado-framework/avocado Length of output: 728 Critical issue: Deprecation warnings are not shown for direct imports—only during test execution. The This means users who import deprecated utilities directly (not as part of a test) receive no warning whatsoever, defeating the purpose of deprecation notices. The implementation requires:
🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1459,3 +1459,9 @@ def get_command_output_matching(command, pattern): | |
| ['file1.txt', 'file2.txt'] | ||
| """ | ||
| return [line for line in run(command).stdout_text.splitlines() if pattern in line] | ||
|
|
||
|
|
||
| # pylint: disable=wrong-import-position | ||
| from avocado.utils.deprecation import log_deprecation | ||
|
|
||
| log_deprecation.warning("process") | ||
|
Comment on lines
+1464
to
+1467
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a custom Using
Consider replacing this with a standard # at the top of avocado/utils/process.py
import warnings
warnings.warn(
"The 'process' utility is deprecated. It has been moved to the AAutils "
"project and will be removed after the next LTS release. For more "
"information, please see: https://github.com/avocado-framework/aautils",
DeprecationWarning,
stacklevel=2
)If the custom References
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,3 +199,9 @@ def make_temp_script(name, content, prefix="avocado_script", mode=DEFAULT_MODE): | |
| scpt = TemporaryScript(name, content, prefix=prefix, mode=mode) | ||
| scpt.save() | ||
| return scpt.path | ||
|
|
||
|
|
||
| # pylint: disable=wrong-import-position | ||
| from avocado.utils.deprecation import log_deprecation | ||
|
|
||
| log_deprecation.warning("script") | ||
|
Comment on lines
+204
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a custom Using
Consider replacing this with a standard # at the top of avocado/utils/script.py
import warnings
warnings.warn(
"The 'script' utility is deprecated. It has been moved to the AAutils "
"project and will be removed after the next LTS release. For more "
"information, please see: https://github.com/avocado-framework/aautils",
DeprecationWarning,
stacklevel=2
)If the custom References
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,3 +102,9 @@ def wait_for(func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=No | |
| time.sleep(step) | ||
|
|
||
| return None | ||
|
|
||
|
|
||
| # pylint: disable=wrong-import-position | ||
| from avocado.utils.deprecation import log_deprecation | ||
|
|
||
| log_deprecation.warning("wait") | ||
|
Comment on lines
+107
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a custom Using
Consider replacing this with a standard # at the top of avocado/utils/wait.py
import warnings
warnings.warn(
"The 'wait' utility is deprecated. It has been moved to the AAutils "
"project and will be removed after the next LTS release. For more "
"information, please see: https://github.com/avocado-framework/aautils",
DeprecationWarning,
stacklevel=2
)If the custom References
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a custom
log_deprecationobject with a bottom-of-file import for deprecation warnings is a possible pattern, but it deviates from standard Python practices. The built-inwarningsmodule is the idiomatic way to handle deprecations.Using
warnings.warn()would:warnings.simplefilteror the-Wcommand-line option).flush()call.Consider replacing this with a standard
DeprecationWarningat the top of the module. For example:If the custom
log_deprecationis required for project-specific logging aggregation, please disregard this suggestion.References