Skip to content

Commit 48bfc53

Browse files
authored
Merge pull request #458 from numpy/in-package-test-dirs
🚚 move the tests to within the individual package dirs as `@test`
2 parents a0e9fdf + 8aa79a6 commit 48bfc53

File tree

171 files changed

+97
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+97
-87
lines changed

β€Žpyproject.toml

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,23 @@ dev = [
9595

9696

9797
[tool.hatch.build]
98-
packages = ["src/_numtype", "src/numtype", "src/numpy-stubs"]
99-
100-
[tool.hatch.build.targets.sdist]
101-
exclude = [
102-
"/.github",
103-
"/.vscode",
104-
"/dist",
105-
"/doc",
106-
"/test",
107-
"/tool",
108-
".mypyignore",
109-
".mypyignore-todo",
110-
"CONTRIBUTING.md",
111-
"uv.lock",
112-
]
98+
exclude = [
99+
"**/@test",
100+
"**/*.yml",
101+
"**/.*",
102+
"/docs",
103+
"/tool",
104+
"CONTRIBUTING.md",
105+
"uv.lock",
106+
]
107+
skip-excluded-dirs = true
108+
109+
[tool.hatch.build.targets.wheel]
110+
packages = ["src/_numtype", "src/numtype", "src/numpy-stubs"]
113111

114112

115113
[tool.mypy]
116114
mypy_path = "src"
117-
explicit_package_bases = true
118-
119115
strict = true
120116
strict_bytes = true
121117
strict_concatenate = true
@@ -137,11 +133,9 @@ disable_memoryview_promotion = true
137133

138134

139135
[tool.pyright]
140-
include = ["src", "test", "tool"]
136+
include = ["src", "tool"]
141137
ignore = [".venv"]
142138
stubPath = "src"
143-
venvPath = "."
144-
venv = ".venv"
145139
pythonPlatform = "All"
146140
typeCheckingMode = "strict"
147141

@@ -152,7 +146,7 @@ enableReachabilityAnalysis = false
152146
reportCallInDefaultInitializer = true
153147
reportImportCycles = true
154148
reportImplicitOverride = true
155-
reportInvalidStubStatement = false # see execution environments
149+
reportInvalidStubStatement = false # required for type-testing
156150
reportMissingSuperCall = false
157151
reportPrivateUsage = false
158152
reportPropertyTypeMismatch = false
@@ -162,7 +156,7 @@ reportUninitializedInstanceVariable = true
162156
reportUnnecessaryTypeIgnoreComment = true
163157
reportUnusedExpression = false
164158
reportUnusedParameter = false
165-
reportUnusedVariable = false
159+
reportUnusedVariable = true
166160
# basedpyright only
167161
failOnWarnings = true
168162
reportIgnoreCommentWithoutRule = true
@@ -174,30 +168,8 @@ reportPrivateLocalImportUsage = true
174168
reportUnannotatedClassAttribute = false
175169
strictGenericNarrowing = true
176170

177-
[[executionEnvironments]]
178-
root = "src"
179-
reportInvalidStubStatement = true
180-
reportUnusedCallResult = true
181-
reportUnusedVariable = true
182-
183-
[[executionEnvironments]]
184-
root = "test"
185-
reportAny = true
186-
reportPrivateUsage = true
187-
reportUnreachable = true
188-
# basedpyright only
189-
reportExplicitAny = true
190-
reportUnsafeMultipleInheritance = true
191-
192-
[[executionEnvironments]]
193-
root = "tool"
194-
reportImplicitOverride = true
195-
reportInvalidStubStatement = true
196-
reportUnusedCallResult = true
197-
198-
199171
[tool.ruff]
200-
src = ["src", "test", "tool"]
172+
src = ["src", "tool"]
201173
extend-exclude = [".git", ".mypy_cache", ".tox", ".venv"]
202174
force-exclude = true
203175
# https://typing.python.org/en/latest/guides/writing_stubs.html#maximum-line-length
@@ -264,6 +236,14 @@ preview = true
264236
allow-dunder-method-names = ["__array__", "__array_ufunc__"]
265237

266238

239+
[tool.pytest.ini_options]
240+
minversion = "8.0"
241+
addopts = ["-ra", "--strict-config", "--strict-markers"]
242+
filterwarnings = ["error"]
243+
log_cli_level = "INFO"
244+
xfail_strict = true
245+
246+
267247
# install tox with `uv tool install tox --with tox-uv --upgrade`
268248
# and run with `uvx tox p`
269249
[tool.tox]

β€Žsrc/_numtype/@test/.ruff.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extend = "../.ruff.toml"
2+
3+
[lint]
4+
extend-ignore = [
5+
"PYI015", # flake8-pyi: assignment-default-in-stub
6+
"PYI017", # flake8-pyi: complex-assignment-in-stub
7+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import _numtype as _nt
2+
import numpy as np
3+
4+
###
5+
# _ToArray1_0d
6+
7+
can_b1_0d: _nt.CanArray0D[np.bool] = np.bool()
8+
can_i1_0d: _nt.CanArray0D[np.int8] = np.int8()
9+
can_i2_0d: _nt.CanArray0D[np.int16] = np.int16()
10+
can_i4_0d: _nt.CanArray0D[np.int32] = np.int32()
11+
can_i8_0d: _nt.CanArray0D[np.int64] = np.int64()
12+
can_u1_0d: _nt.CanArray0D[np.uint8] = np.uint8()
13+
can_u2_0d: _nt.CanArray0D[np.uint16] = np.uint16()
14+
can_u4_0d: _nt.CanArray0D[np.uint32] = np.uint32()
15+
can_u8_0d: _nt.CanArray0D[np.uint64] = np.uint64()
16+
can_f2_0d: _nt.CanArray0D[np.float16] = np.float16()
17+
can_f4_0d: _nt.CanArray0D[np.float32] = np.float32()
18+
can_f8_0d: _nt.CanArray0D[np.float64] = np.float64()
19+
can_ld_0d: _nt.CanArray0D[np.longdouble] = np.longdouble()
20+
can_c8_0d: _nt.CanArray0D[np.complex64] = np.complex64()
21+
can_c16_0d: _nt.CanArray0D[np.complex128] = np.complex128()
22+
can_cld_0d: _nt.CanArray0D[np.clongdouble] = np.clongdouble()
23+
can_O_0d: _nt.CanArray0D[np.object_] = np.empty((), np.object_)
24+
can_M_0d: _nt.CanArray0D[np.datetime64] = np.datetime64(None)
25+
can_m_0d: _nt.CanArray0D[np.timedelta64] = np.timedelta64(None)
26+
can_S_0d: _nt.CanArray0D[np.bytes_] = np.bytes_(b"")
27+
can_U_0d: _nt.CanArray0D[np.str_] = np.str_("")
28+
can_V_0d: _nt.CanArray0D[np.void] = np.void(b"")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import _numtype as _nt
2+
3+
class A: ...
4+
5+
a0d: A
6+
a1d: list[A]
7+
a2d: list[list[A]]
8+
a3d: list[list[list[A]]]
9+
a4d: list[list[list[list[A]]]]
10+
11+
###
12+
13+
a1nd__a_0d: _nt.Sequence1ND[A] = a0d # type: ignore[assignment] # pyright: ignore[reportAssignmentType]
14+
a1nd__a_1d: _nt.Sequence1ND[A] = a1d
15+
a1nd__a_2d: _nt.Sequence1ND[A] = a2d
16+
a1nd__a_3d: _nt.Sequence1ND[A] = a3d
17+
a1nd__a_4d: _nt.Sequence1ND[A] = a4d

β€Žtest/static/test__numtype.pyi renamed to β€Žsrc/_numtype/@test/test_to_array.pyi

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,6 @@ S_3d: list[list[list[bytes]]]
4444
U_3d: list[list[list[str]]]
4545
O_3d: list[list[list[object]]]
4646

47-
###
48-
# nested sequence
49-
50-
nested_bool_1d: _nt.Sequence1ND[bool] = b_1d
51-
nested_bool_2d: _nt.Sequence1ND[bool] = b_2d
52-
53-
###
54-
# _ToArray1_0d
55-
56-
can_b1_0d: _nt.CanArray0D[np.bool] = np.bool()
57-
can_i1_0d: _nt.CanArray0D[np.int8] = np.int8()
58-
can_i2_0d: _nt.CanArray0D[np.int16] = np.int16()
59-
can_i4_0d: _nt.CanArray0D[np.int32] = np.int32()
60-
can_i8_0d: _nt.CanArray0D[np.int64] = np.int64()
61-
can_u1_0d: _nt.CanArray0D[np.uint8] = np.uint8()
62-
can_u2_0d: _nt.CanArray0D[np.uint16] = np.uint16()
63-
can_u4_0d: _nt.CanArray0D[np.uint32] = np.uint32()
64-
can_u8_0d: _nt.CanArray0D[np.uint64] = np.uint64()
65-
can_f2_0d: _nt.CanArray0D[np.float16] = np.float16()
66-
can_f4_0d: _nt.CanArray0D[np.float32] = np.float32()
67-
can_f8_0d: _nt.CanArray0D[np.float64] = np.float64()
68-
can_ld_0d: _nt.CanArray0D[np.longdouble] = np.longdouble()
69-
can_c8_0d: _nt.CanArray0D[np.complex64] = np.complex64()
70-
can_c16_0d: _nt.CanArray0D[np.complex128] = np.complex128()
71-
can_cld_0d: _nt.CanArray0D[np.clongdouble] = np.clongdouble()
72-
can_O_0d: _nt.CanArray0D[np.object_] = np.empty((), np.object_)
73-
can_M_0d: _nt.CanArray0D[np.datetime64] = np.datetime64(None)
74-
can_m_0d: _nt.CanArray0D[np.timedelta64] = np.timedelta64(None)
75-
can_S_0d: _nt.CanArray0D[np.bytes_] = np.bytes_(b"")
76-
can_U_0d: _nt.CanArray0D[np.str_] = np.str_("")
77-
can_V_0d: _nt.CanArray0D[np.void] = np.void(b"")
78-
7947
###
8048
# bool
8149

@@ -144,4 +112,4 @@ bool_3nd_reject_2d: _nt.ToBool_3nd = b1_2d # type: ignore[assignment] # pyrigh
144112
bool_3nd_accept_3d: _nt.ToBool_3nd = b1_3d
145113

146114
###
147-
# TODO(jorenham): repeat for all the other `_To` and `_Co` types (codegen)
115+
# TODO(jorenham): repeat for all the other `_To` array-like types (codegen)

β€Žtest/.ruff.toml renamed to β€Žsrc/numpy-stubs/@test/.ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extend = "../pyproject.toml"
1+
extend = "../../../pyproject.toml"
22
line-length = 88
33

44
[lint]

β€Žtest/README.md renamed to β€Žsrc/numpy-stubs/@test/README.md

Lines changed: 3 additions & 3 deletions

0 commit comments

Comments
Β (0)