Commit 8adb749
authored
* Hide read_to_array from xrspatial.geotiff public namespace (#1708)
The api-consistency sweep on 2026-05-12 flagged an orphan-API leak:
xrspatial/geotiff/__init__.py imports ``read_to_array`` from ``._reader``
so the eager ``open_geotiff`` body can call it, but as a side-effect
that bound the name in the public ``xrspatial.geotiff`` namespace.
``__all__`` does not list it, the module-level "Public API" docstring
does not document it, and the Sphinx pages do not advertise it -- but
``from xrspatial.geotiff import read_to_array`` worked anyway.
The library's own ``test_band_validation_1673.py`` imported it that way
six times, proving the leak was being used as if it were public.
External users who pattern-matched against the test would also be
relying on a name the maintainer never committed to support. A future
cleanup that removed the top-level import would have broken them with
no deprecation path.
This change binds the helper under a leading-underscore name in
``__init__.py``:
from ._reader import UnsafeURLError
from ._reader import read_to_array as _read_to_array
and updates each internal call site (six call sites: ``open_geotiff``,
the dask delayed window reader, and four GPU-fallback paths in
``read_geotiff_gpu``). The single test file that imported the leaked
name is updated to import from ``xrspatial.geotiff._reader`` directly,
which is the canonical private path.
``test_namespace_no_leak_1708.py`` pins the namespace contract:
``read_to_array`` must not be an attribute of ``xrspatial.geotiff``,
``__all__`` must not list it, and the canonical
``xrspatial.geotiff._reader.read_to_array`` import must still work.
This guards against a future maintainer re-adding a bare
``from ._reader import read_to_array`` line without realising it would
re-leak the name.
No runtime behaviour change in the supported public API. The deprecated
``plot_geotiff`` continues to be exposed at the top level for backward
compatibility because it has a documented deprecation path; this commit
takes no position on ``plot_geotiff``.
Closes #1708.
* Patch _read_to_array alias in dask astype trace test
The #1708 cleanup hid ``read_to_array`` from ``xrspatial.geotiff`` and
bound the internal alias as ``_read_to_array``. The existing #1624
trace test still set ``xrspatial.geotiff.read_to_array`` via
monkeypatch, which now raises ``AttributeError`` at the setattr call.
Patch the alias the dask worker actually reads instead.
1 parent 258d16c commit 8adb749
4 files changed
Lines changed: 95 additions & 17 deletions
File tree
- xrspatial/geotiff
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
| |||
807 | 814 | | |
808 | 815 | | |
809 | 816 | | |
810 | | - | |
| 817 | + | |
811 | 818 | | |
812 | 819 | | |
813 | 820 | | |
| |||
2171 | 2178 | | |
2172 | 2179 | | |
2173 | 2180 | | |
2174 | | - | |
2175 | | - | |
2176 | | - | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
2177 | 2184 | | |
2178 | 2185 | | |
2179 | 2186 | | |
| |||
2677 | 2684 | | |
2678 | 2685 | | |
2679 | 2686 | | |
2680 | | - | |
| 2687 | + | |
2681 | 2688 | | |
2682 | 2689 | | |
2683 | 2690 | | |
| |||
2843 | 2850 | | |
2844 | 2851 | | |
2845 | 2852 | | |
2846 | | - | |
| 2853 | + | |
2847 | 2854 | | |
2848 | 2855 | | |
2849 | 2856 | | |
| |||
2856 | 2863 | | |
2857 | 2864 | | |
2858 | 2865 | | |
2859 | | - | |
| 2866 | + | |
2860 | 2867 | | |
2861 | 2868 | | |
2862 | 2869 | | |
| |||
2913 | 2920 | | |
2914 | 2921 | | |
2915 | 2922 | | |
2916 | | - | |
| 2923 | + | |
2917 | 2924 | | |
2918 | 2925 | | |
2919 | 2926 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
| 114 | + | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
0 commit comments