Skip to content

Commit 841a9ca

Browse files
authored
CLN: #1836 merge mypy_strict into mypy (#1866)
* merge mypy_strict into mypy * ty * py311 * py311 again * mypy_dist
1 parent 42f5459 commit 841a9ca

16 files changed

Lines changed: 46 additions & 61 deletions

File tree

.github/workflows/comment_commands.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
actions: write
1717
checks: write
1818
# if more commands are added, they will need to be added here too as we don't have access to env at this stage
19-
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/mypy_nightly", "/mypy_strict", "/pyrefly_strict", "/pyrefly_all", "/ty_all"]'), github.event.comment.body) && github.event.comment.author_association == 'MEMBER'
19+
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/mypy_nightly", "/pyrefly_strict", "/pyrefly_all", "/ty_all"]'), github.event.comment.body) && github.event.comment.author_association == 'MEMBER'
2020

2121
steps:
2222
- name: Resolve comment command
@@ -34,10 +34,6 @@ jobs:
3434
echo "poe_command=mypy --mypy_nightly" >> "${GITHUB_OUTPUT}"
3535
echo "check_name=Mypy nightly tests" >> "${GITHUB_OUTPUT}"
3636
;;
37-
/mypy_strict)
38-
echo "poe_command=mypy_strict" >> "${GITHUB_OUTPUT}"
39-
echo "check_name=Mypy strict tests" >> "${GITHUB_OUTPUT}"
40-
;;
4137
/pyrefly_strict)
4238
echo "poe_command=pyrefly_strict" >> "${GITHUB_OUTPUT}"
4339
echo "check_name=Pyrefly tests strict preset" >> "${GITHUB_OUTPUT}"

.github/workflows/optional.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: ./.github/setup
2626
with:
2727
os: ubuntu-latest
28-
python-version: '3.11'
28+
python-version: '3.14'
2929

3030
- name: Run pytest (against pandas nightly)
3131
run: poetry run poe pytest --nightly
@@ -46,33 +46,11 @@ jobs:
4646
uses: ./.github/setup
4747
with:
4848
os: ubuntu-latest
49-
python-version: '3.11'
49+
python-version: '3.14'
5050

5151
- name: Run mypy tests with mypy nightly
5252
run: poetry run poe mypy --mypy_nightly
5353

54-
55-
mypy_strict:
56-
runs-on: ubuntu-latest
57-
timeout-minutes: 10
58-
permissions:
59-
contents: read
60-
actions: write
61-
62-
steps:
63-
- uses: actions/checkout@v7
64-
with:
65-
persist-credentials: false
66-
67-
- name: Install project dependencies
68-
uses: ./.github/setup
69-
with:
70-
os: ubuntu-latest
71-
python-version: '3.11'
72-
73-
- name: Run mypy tests with all optional errors enabled
74-
run: poetry run poe mypy_strict
75-
7654
pyrefly_strict:
7755
runs-on: ubuntu-latest
7856
timeout-minutes: 10
@@ -84,7 +62,7 @@ jobs:
8462
uses: ./.github/setup
8563
with:
8664
os: ubuntu-latest
87-
python-version: '3.11'
65+
python-version: '3.14'
8866

8967
- name: Run pyrefly tests with preset 'strict'
9068
run: poetry run poe pyrefly_strict
@@ -100,7 +78,7 @@ jobs:
10078
uses: ./.github/setup
10179
with:
10280
os: ubuntu-latest
103-
python-version: '3.11'
81+
python-version: '3.14'
10482

10583
- name: Run pyrefly tests with preset 'all'
10684
run: poetry run poe pyrefly_all
@@ -116,7 +94,7 @@ jobs:
11694
uses: ./.github/setup
11795
with:
11896
os: ubuntu-latest
119-
python-version: '3.11'
97+
python-version: '3.14'
12098

12199
- name: Run ty tests with all rules raising errors
122100
run: poetry run poe ty_all

docs/tests.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ The following tests are **optional**. Some of them are run by the CI but it is o
2121

2222
- Run pytest against pandas nightly: `poe pytest --nightly`
2323
- Use mypy nightly to validate the annotations: `poe mypy --mypy_nightly`
24-
- Use mypy with [all optional errors enabled](https://mypy.readthedocs.io/en/stable/config_file.html#confval-strict): `poe mypy_strict`
2524
- Use pyrefly with [preset](https://pyrefly.org/en/docs/configuration/#preset) 'strict': `poe pyrefly_strict`
2625
- Use pyrefly with preset 'all': `poe pyrefly_all`
2726
- Use ty with [all rules raising errors](https://docs.astral.sh/ty/rules/#rule-levels): `poe ty_all`
@@ -31,7 +30,6 @@ Among the tests above, the following can be run directly during a PR by commenti
3130

3231
- Run pytest against pandas nightly by commenting `/pandas_nightly`
3332
- Use mypy nightly to validate the annotations by commenting `/mypy_nightly`
34-
- Use mypy with all optional errors enabled: `/mypy_strict`
3533
- Use pyrefly with preset 'strict': `/pyrefly_strict`
3634
- Use pyrefly with preset 'all': `/pyrefly_all`
3735
- Use ty with all rules raising errors: `/ty_all`

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ script = "scripts.test:mypy_src(mypy_nightly)"
150150
help = "Run mypy on 'tests' using the installed stubs"
151151
script = "scripts.test:run_tests(dist=True, type_checker='mypy')"
152152

153-
[tool.poe.tasks.mypy_strict]
154-
help = "Run mypy on 'tests' (using the local stubs) and on the local stubs with all optional errors enabled"
155-
script = "scripts.test.run:mypy_src_strict"
156-
157153
[tool.poe.tasks.stubtest]
158154
script = "scripts.test:stubtest(allowlist, check_missing, nightly)"
159155
help = "Run stubtest to compare the installed stubs against pandas"
@@ -362,6 +358,7 @@ python-platform = "all"
362358

363359
[tool.ty.rules]
364360
possibly-unresolved-reference = "error"
361+
missing-type-argument = "error"
365362

366363
[tool.ty.analysis]
367364
respect-type-ignore-comments = false

scripts/test/_step.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
name="Run mypy on 'tests' (using the local stubs) and on the local stubs",
3030
run=run.mypy_src,
3131
)
32-
mypy_src_strict = Step(
33-
name="Run mypy on 'tests' (using the local stubs) and on the local stubs with all optional errors enabled",
34-
run=run.mypy_src_strict,
35-
)
3632
pytest = Step(name="Run pytest", run=run.pytest)
3733
style = Step(name="Run pre-commit", run=run.style)
3834
build_dist = Step(name="Build pandas-stubs", run=run.build_dist)

scripts/test/run.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88

99
def mypy_src() -> None:
10-
cmd = ["mypy", "pandas-stubs", "tests", "--no-incremental"]
11-
subprocess.run(cmd, check=True)
12-
13-
14-
def mypy_src_strict() -> None:
1510
cmd = ["mypy", "pandas-stubs", "tests", "--no-incremental", "--strict"]
1611
subprocess.run(cmd, check=True)
1712

@@ -77,7 +72,7 @@ def rename_src() -> None:
7772

7873

7974
def mypy_dist() -> None:
80-
cmd = ["mypy", "tests", "--no-incremental"]
75+
cmd = ["mypy", "tests", "--no-incremental", "--strict"]
8176
subprocess.run(cmd, check=True)
8277

8378

tests/extension/decimal/array.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ def astype(self, dtype: ExtensionDtype, copy: bool = True) -> ExtensionArray: ..
235235
@overload
236236
def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: ...
237237

238-
def astype(self, dtype: Dtype, copy: bool = True):
238+
def astype(
239+
self, dtype: Dtype, copy: bool = True
240+
) -> np_1darray | ExtensionArray | ArrayLike:
239241
if is_dtype_equal(dtype, self._dtype):
240242
if not copy:
241243
return self
@@ -323,7 +325,7 @@ def convert_values(param: Any) -> ExtensionArray | list[Any]:
323325
else:
324326
# Assume it's an object
325327
ovalues = [param] * len(self)
326-
return ovalues
328+
return ovalues # type: ignore[no-any-return]
327329

328330
lvalues = self
329331
rvalues = convert_values(other)

tests/frame/test_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def getCols(k: int) -> str:
8282

8383

8484
def makeStringIndex(k: int = 10) -> pd.Index:
85-
return pd.Index(rands_array(nchars=10, size=k), name=None)
85+
return pd.Index(rands_array(nchars=10, size=k), name=None) # type: ignore[no-any-return]
8686

8787

8888
def rands_array(nchars: int, size: int) -> np_ndarray:

tests/frame/test_groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def test_types_groupby_agg() -> None:
294294
check(assert_type(df.groupby("col1").agg(agg_dict1), pd.DataFrame), pd.DataFrame)
295295

296296
def wrapped_min(x: pd.Series) -> Scalar:
297-
return x.min()
297+
return x.min() # type: ignore[no-any-return]
298298

299299
# TODO: https://github.com/facebook/pyrefly/issues/3891
300300
check(

tests/series/test_properties.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
# mypy: disable-error-code=type-arg
12
# pyright: reportMissingTypeArgument=false
3+
# ty: ignore[missing-type-argument]
24
from typing import (
35
TYPE_CHECKING,
46
assert_type,

0 commit comments

Comments
 (0)