-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add validation to catch legacy imports #6081
Conversation
Codecov Report
|
datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/imports.py
Outdated
Show resolved
Hide resolved
echo_debug(f'Checking {check_name}') | ||
|
||
# focus on check and testing directories | ||
bases = [os.path.join(integrations_root, check_name, base) for base in ('datadog_checks', 'tests')] |
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.
nit: some of the file/directory logic could be moved to functions in utils
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.
Could you clarify this one a bit? Which functions would be useful in as a utility function?
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.
I was thinking something like turning this line into get_python_files_for_check(check)
or something like that. It could be useful for future scripts
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.
This is a good idea - but may be better suited for a separate PR. There are several options which could be helpful and not sure those discussions would be suited for here.
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.
👍
datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/imports.py
Show resolved
Hide resolved
datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/imports.py
Show resolved
Hide resolved
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.
Nice! Tested out locally
Validating imports avoiding deprecated modules ...
Validation failed: 152 deprecated imports found in 113 files:
/Users/christine.chen/dev/integrations-core/active_directory/datadog_checks/active_directory/active_directory.py: line # 3
from datadog_checks.checks.win import PDHBaseCheck
/Users/christine.chen/dev/integrations-core/activemq_xml/datadog_checks/activemq_xml/activemq_xml.py: line # 8
from datadog_checks.checks import AgentCheck
...
Motivation
The
datadog_checks
package was rearranged for all packages to be hosted under thebase
sub package. The original module locations have been updated to redirect to those imports for backwards compatibility, but usage of them is deprecated.This tool will identify those imports and report them as errors, for future use in our CI.
It also includes an
autofix
option, to aid in the initial mass migration of changing all the files en masse before we introduce this validation to CI.