Move datadog_checks_base code into sub base package #2167
Merged
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.
What does this PR do?
Creates a
base
package indatadog_checks_base
and moves the existing code into that package.Also updates all the imports to include the new addition of
.base.
Motivation
Since we use the
datadog_checks
namespace for all of our checks, they need to have the same__init__.py
file. Currently the init file for the datadog_checks_base includes the version of the base package. When a new check gets installed, since the new check shares the namespace, the init file can be overwritten by the contents of the new check's file. There is additionally a warning about this in the python packaging docs - https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packagesThe solution here is to make the init file identical to the rest, and move the base code into its own sub package where the version lives in that packages init file.
Review checklist
no-changelog
label attachedAdditional Notes
We will need to do this for integrations-extras as well. This is the script I made/used to update the imports: