chore(lint): migrate os.environ to env in appsec modules#17218
Open
chore(lint): migrate os.environ to env in appsec modules#17218
Conversation
Migrate `os.environ`/`os.getenv` to `ddtrace.internal.settings.env` in: - ddtrace/appsec/_iast/ (5 files) - ddtrace/appsec/_processor.py - ddtrace/contrib/internal/subprocess/patch.py - ddtrace/internal/settings/asm.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Mar 31, 2026
bm1549
added a commit
that referenced
this pull request
Mar 31, 2026
All `os.environ`/`os.getenv` usages in `ddtrace/` have been migrated to `ddtrace.internal.settings.env` via the split migration PRs: - apm-sdk-capabilities-python: #16724 - apm-core-python: #16725 - ci-app-libraries: #16726 - apm-idm-python (contrib): #16727 - asm-python: #17218 - ml-observability: #17219 - profiling-python: #17220 - data-streams-monitoring: #17221 This PR removes the "to be migrated" ignore lists, leaving only the permanent exceptions: - ddtrace/__init__.py — bootstrap: circular import with settings - ddtrace/internal/native/__init__.py — bootstrap: imported before settings Merge after all 8 migration PRs above are merged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gh-worker-dd-mergequeue-cf854d bot
pushed a commit
that referenced
this pull request
Mar 31, 2026
## Description Part of a series migrating all `os.environ`/`os.getenv` usage in `ddtrace/` to the centralized `env` MutableMapping from `ddtrace.internal.settings` (introduced in #17149). **This PR covers `@DataDog/profiling-python` owned files (3 files):** - `ddtrace/internal/core/crashtracking.py` - `ddtrace/internal/datadog/profiling/code_provenance.py` - `ddtrace/internal/settings/profiling.py` **Stacks on:** #17149 **Sister PRs (same migration, different owners):** - `apm-sdk-capabilities-python`: #16724 - `apm-core-python`: #16725 - `ci-app-libraries`: #16726 - `apm-idm-python` (contrib): #16727 - `asm-python`: #17218 - `ml-observability`: #17219 ## Testing - All ruff checks pass (`ruff check --no-cache .`) - All ast-grep tests pass (`sg test`) - No Python syntax errors in migrated files ## Risks None — mechanical replacement of `os.environ` → `env` and `os.getenv(k)` → `env.get(k)`. No logic changes. ## Additional Notes The `env` object is a `MutableMapping` wrapping `os.environ`, so it is a drop-in replacement. See #17149 for design details. Co-authored-by: brian.marks <brian.marks@datadoghq.com>
gh-worker-dd-mergequeue-cf854d bot
pushed a commit
that referenced
this pull request
Apr 1, 2026
## Description Part of a series migrating all `os.environ`/`os.getenv` usage in `ddtrace/` to the centralized `env` MutableMapping from `ddtrace.internal.settings` (introduced in #17149). **This PR covers `@DataDog/ml-observability` owned files (3 files):** - `ddtrace/contrib/internal/mcp/patch.py` - `ddtrace/contrib/internal/ray/patch.py` - `ddtrace/contrib/internal/ray/utils.py` **Stacks on:** #17149 **Sister PRs (same migration, different owners):** - `apm-sdk-capabilities-python`: #16724 - `apm-core-python`: #16725 - `ci-app-libraries`: #16726 - `apm-idm-python` (contrib): #16727 - `asm-python`: #17218 ## Testing - All ruff checks pass (`ruff check --no-cache .`) - All ast-grep tests pass (`sg test`) - No Python syntax errors in migrated files ## Risks None — mechanical replacement of `os.environ` → `env` and `os.getenv(k)` → `env.get(k)`. No logic changes. ## Additional Notes The `env` object is a `MutableMapping` wrapping `os.environ`, so it is a drop-in replacement. See #17149 for design details. Co-authored-by: brian.marks <brian.marks@datadoghq.com>
christophe-papazian
approved these changes
Apr 1, 2026
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.
Description
Part of a series migrating all
os.environ/os.getenvusage inddtrace/to the centralizedenvMutableMapping fromddtrace.internal.settings(introduced in #17149).This PR covers
@DataDog/asm-pythonowned files (8 files):ddtrace/appsec/_iast/__init__.pyddtrace/appsec/_iast/_ast/ast_patching.pyddtrace/appsec/_iast/reporter.pyddtrace/appsec/_iast/taint_sinks/weak_cipher.pyddtrace/appsec/_iast/taint_sinks/weak_hash.pyddtrace/appsec/_processor.pyddtrace/contrib/internal/subprocess/patch.pyddtrace/internal/settings/asm.pyStacks on: #17149
Sister PRs (same migration, different owners):
apm-sdk-capabilities-python: chore(lint): migrate os.environ to env in sdk-capabilities modules #16724apm-core-python: chore(lint): migrate os.environ to env in core modules #16725ci-app-libraries: chore(lint): migrate os.environ to env in CI visibility modules #16726apm-idm-python(contrib): chore(lint): migrate os.environ to env in contrib integrations #16727Testing
ruff check --no-cache .)sg test)Risks
None — mechanical replacement of
os.environ→envandos.getenv(k)→env.get(k). No logic changes.Additional Notes
The
envobject is aMutableMappingwrappingos.environ, so it is a drop-in replacement. See #17149 for design details.