Commit 059e43f
committed
types: rename dvc/types.py to dvc/_types.py to remove stdlib shadow
The previous two attempts at #11035 (53d6d6b: `-m dvc`, then 26b5514:
`-c "from dvc.cli import main; ..."`) both broke
`tests/func/experiments/test_experiments.py::test_run_celery` on every
Python version (3.9-3.14) on Windows. Master is green for that test
including 3.14, so the Windows-specific celery worker spawn path
genuinely depends on the script form -- changing the launch shape is
not a viable fix even when both alternatives keep sys.path[0] empty.
Address the root cause structurally instead: rename the internal
`dvc/types.py` module (containing `StrPath`, `DictStrAny`, `TargetType`,
etc.) to `dvc/_types.py`. The leading underscore both signals "private"
and -- more importantly -- removes any name collision with stdlib
`types`, so no matter how the daemon worker is launched (script form,
`-m dvc`, `-c`, pipx-installed shim, ...) no entry on sys.path can
shadow stdlib `types` via the dvc package.
Daemon launch shape is reverted to the original script form
(`python <site-packages>/dvc/__main__.py ...`) -- identical to master.
This is what kept the Windows celery worker test green for years, and
is what we want to keep working. The `dvc/_types.py` rename is what
fixes the underlying Python 3.14 shadow risk for the user-reported
case (#11035 reporter installs via pipx).
Files updated:
- dvc/types.py -> dvc/_types.py (rename, content unchanged)
- 19 internal call sites: `from dvc.types import X` -> `from dvc._types import X`
- dvc/daemon.py: revert _get_dvc_args to master's script form
- tests/unit/test_daemon.py: regression test asserting `dvc/types.py`
does not exist and that stdlib `types` is not resolved to a dvc
module. This guards against someone reintroducing the file later.
The rename is a backward-incompatible internal API change in principle,
but `dvc/types.py` was undocumented and the aliases are only meant for
internal use (see imports across the codebase -- all internal). No
external consumers are likely to depend on `from dvc.types import ...`
because the public type surface is exposed via `dvc.api`, `dvc.repo`,
etc., not via the type-alias module.1 parent 51f513d commit 059e43f
23 files changed
Lines changed: 51 additions & 77 deletions
File tree
- dvc
- fs
- parsing
- render
- converter
- repo
- plots
- stage
- testing/benchmarks
- ui
- utils
- serialize
- tests/unit
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
85 | 65 | | |
86 | 66 | | |
87 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
0 commit comments