Skip to content

chore(lint): remove migrated-path ignores from os-environ sg rules#17222

Draft
bm1549 wants to merge 1 commit intomainfrom
brian.marks/migrate-sg-rules-cleanup
Draft

chore(lint): remove migrated-path ignores from os-environ sg rules#17222
bm1549 wants to merge 1 commit intomainfrom
brian.marks/migrate-sg-rules-cleanup

Conversation

@bm1549
Copy link
Copy Markdown
Contributor

@bm1549 bm1549 commented Mar 31, 2026

Description

Final cleanup PR for the os.environddtrace.internal.settings.env migration.

Removes the # --- Pre-existing os.environ usage (to be migrated in follow-up PRs) --- ignore lists from all 4 os-environ ast-grep rules, leaving only the two permanent bootstrap exceptions that can never be migrated due to circular imports.

⚠️ Merge order: merge this AFTER all 8 migration PRs below are merged.

PR Team
#16724 apm-sdk-capabilities-python
#16725 apm-core-python
#16726 ci-app-libraries
#16727 apm-idm-python (contrib)
#17218 asm-python
#17219 ml-observability
#17220 profiling-python
#17221 data-streams-monitoring

Permanent exceptions retained:

  • ddtrace/__init__.py — bootstrap module, circular import with settings
  • ddtrace/internal/native/__init__.py — bootstrap module, imported before settings is available

Testing

  • All ast-grep tests pass (sg test)
  • sg scan produces no violations once all migration PRs are merged

Risks

None if merged after all migration PRs. Merging before will cause ast-grep rules CI failures on other PRs.

Additional Notes

See #17149 for the env MutableMapping design.

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>
@bm1549 bm1549 added changelog/no-changelog A changelog entry is not required for this PR. AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos labels Mar 31, 2026
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Codeowners resolved as

.sg/rules/os-environ-fix-access.yml                                     @DataDog/apm-core-python
.sg/rules/os-environ-fix-getenv.yml                                     @DataDog/apm-core-python
.sg/rules/os-environ-fix-import.yml                                     @DataDog/apm-core-python
.sg/rules/os-environ-usage.yml                                          @DataDog/apm-core-python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant