Skip to content

Comments

[ty] Rename src.root setting to environment.root#18760

Merged
MichaReiser merged 3 commits intomainfrom
micha/rename-src-root-to-environment-root
Jun 24, 2025
Merged

[ty] Rename src.root setting to environment.root#18760
MichaReiser merged 3 commits intomainfrom
micha/rename-src-root-to-environment-root

Conversation

@MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Jun 18, 2025

Summary

Renames the src.root setting to environment.root because it doesn't configure what files to check, it configures the search paths.

I'm open to better names. I think environment.root works but I don't love it.

I also noticed that there's some overlap between environment.root and src.include. E.g. if you set include = ["src"], then you probably also want to set environment.root = "src".
Although I think it's more common that people exclude certain directories rather than only including src or test.

I kept the old setting around for now and added a deprecation warning. If both src.root and environment.root are set, environment.root wins.

Test Plan

Added tests

@MichaReiser MichaReiser added configuration Related to settings and configuration ty Multi-file analysis & type inference labels Jun 18, 2025
@MichaReiser MichaReiser force-pushed the micha/rename-src-root-to-environment-root branch from 9f3e6ec to cef0ebd Compare June 18, 2025 16:18
@github-actions
Copy link
Contributor

mypy_primer results

Changes were detected when running on open source projects
psycopg (https://github.com/psycopg/psycopg)
+ warning[deprecated-setting] The `src.root` setting is deprecated. Use `environment.root` instead.
- Found 905 diagnostics
+ Found 906 diagnostics

@github-actions
Copy link
Contributor

github-actions bot commented Jun 18, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser force-pushed the micha/rename-src-root-to-environment-root branch from cef0ebd to bcb6ec1 Compare June 19, 2025 09:45
@AlexWaygood
Copy link
Member

mypy_primer results

Changes were detected when running on open source projects

psycopg (https://github.com/psycopg/psycopg)
+ warning[deprecated-setting] The `src.root` setting is deprecated. Use `environment.root` instead.
- Found 905 diagnostics
+ Found 906 diagnostics

looks like we'll need to update the mypy_primer config for psycopg (and maybe some others too? Haven't checked): https://github.com/hauntsaninja/mypy_primer/blob/7c847cc51ed164d98c0a201539d61c974d418643/mypy_primer/projects.py#L1215

@AlexWaygood
Copy link
Member

I'm open to better names. I think environment.root works but I don't love it.

environment.first_party_root maybe? No strong opinion though :-)

@MichaReiser MichaReiser force-pushed the micha/rename-src-root-to-environment-root branch from bcb6ec1 to 6059dda Compare June 24, 2025 10:48
@sharkdp sharkdp removed their request for review June 24, 2025 11:54
@MichaReiser MichaReiser merged commit 0194452 into main Jun 24, 2025
36 checks passed
@MichaReiser MichaReiser deleted the micha/rename-src-root-to-environment-root branch June 24, 2025 12:40
dcreager added a commit that referenced this pull request Jun 24, 2025
* main:
  [ty] Fix false positives when subscripting an object inferred as having an `Intersection` type (#18920)
  [`flake8-use-pathlib`] Add autofix for `PTH202` (#18763)
  [ty] Add relative import completion tests
  [ty] Clarify what "cursor" means
  [ty] Add a cursor test builder
  [ty] Enforce sort order of completions (#18917)
  [formatter] Fix missing blank lines before decorated classes in .pyi files (#18888)
  Apply fix availability and applicability when adding to `DiagnosticGuard` and remove `NoqaCode::rule` (#18834)
  py-fuzzer: allow relative executable paths (#18915)
  [ty] Change `environment.root` to accept multiple paths (#18913)
  [ty] Rename `src.root` setting to `environment.root` (#18760)
  Use file path for detecting package root (#18914)
  Consider virtual path for various server actions (#18910)
  [ty] Introduce `UnionType::try_from_elements` and `UnionType::try_map` (#18911)
  [ty] Support narrowing on `isinstance()`/`issubclass()` if the second argument is a dynamic, intersection, union or typevar type (#18900)
  [ty] Add decorator check for implicit attribute assignments (#18587)
  [`ruff`] Trigger `RUF037` for empty string and byte strings (#18862)
  [ty] Avoid duplicate diagnostic in unpacking (#18897)
  [`pyupgrade`] Extend version detection to include `sys.version_info.major` (`UP036`) (#18633)
  [`ruff`] Frozen Dataclass default should be valid (`RUF009`) (#18735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Related to settings and configuration ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants