Skip to content

Commit d926eb6

Browse files
authored
Merge branch 'jairo-build' into mypyc-opt-value-types
2 parents 4fde6f9 + c650f24 commit d926eb6

File tree

125 files changed

+5530
-4041
lines changed

Some content is hidden

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

125 files changed

+5530
-4041
lines changed

.github/workflows/mypy_primer.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,35 @@ jobs:
6969
--output concise \
7070
| tee diff_${{ matrix.shard-index }}.txt
7171
) || [ $? -eq 1 ]
72-
- name: Upload mypy_primer diff
73-
uses: actions/upload-artifact@v3
74-
with:
75-
name: mypy_primer_diffs
76-
path: diff_${{ matrix.shard-index }}.txt
77-
- if: ${{ matrix.shard-index }} == 0
72+
- if: ${{ matrix.shard-index == 0 }}
7873
name: Save PR number
7974
run: |
8075
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
81-
- if: ${{ matrix.shard-index }} == 0
82-
name: Upload PR number
83-
uses: actions/upload-artifact@v3
76+
- if: ${{ matrix.shard-index == 0 }}
77+
name: Upload mypy_primer diff + PR number
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: mypy_primer_diffs-${{ matrix.shard-index }}
81+
path: |
82+
diff_${{ matrix.shard-index }}.txt
83+
pr_number.txt
84+
- name: Upload mypy_primer diff
85+
uses: actions/upload-artifact@v4
86+
if: ${{ matrix.shard-index != 0 }}
87+
with:
88+
name: mypy_primer_diffs-${{ matrix.shard-index }}
89+
path: diff_${{ matrix.shard-index }}.txt
90+
91+
join_artifacts:
92+
name: Join artifacts
93+
runs-on: ubuntu-latest
94+
needs: [mypy_primer]
95+
permissions:
96+
contents: read
97+
steps:
98+
- name: Merge artifacts
99+
uses: actions/upload-artifact/merge@v4
84100
with:
85101
name: mypy_primer_diffs
86-
path: pr_number.txt
102+
pattern: mypy_primer_diffs-*
103+
delete-merged: true

.github/workflows/mypy_primer_comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1919
steps:
2020
- name: Download diffs
21-
uses: actions/github-script@v6
21+
uses: actions/github-script@v7
2222
with:
2323
script: |
2424
const fs = require('fs');

misc/apply-cache-diff.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from __future__ import annotations
99

1010
import argparse
11-
import json
1211
import os
1312
import sys
1413

1514
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1615

1716
from mypy.metastore import FilesystemMetadataStore, MetadataStore, SqliteMetadataStore
17+
from mypy.util import json_dumps, json_loads
1818

1919

2020
def make_cache(input_dir: str, sqlite: bool) -> MetadataStore:
@@ -26,21 +26,21 @@ def make_cache(input_dir: str, sqlite: bool) -> MetadataStore:
2626

2727
def apply_diff(cache_dir: str, diff_file: str, sqlite: bool = False) -> None:
2828
cache = make_cache(cache_dir, sqlite)
29-
with open(diff_file) as f:
30-
diff = json.load(f)
29+
with open(diff_file, "rb") as f:
30+
diff = json_loads(f.read())
3131

32-
old_deps = json.loads(cache.read("@deps.meta.json"))
32+
old_deps = json_loads(cache.read("@deps.meta.json"))
3333

3434
for file, data in diff.items():
3535
if data is None:
3636
cache.remove(file)
3737
else:
3838
cache.write(file, data)
3939
if file.endswith(".meta.json") and "@deps" not in file:
40-
meta = json.loads(data)
40+
meta = json_loads(data)
4141
old_deps["snapshot"][meta["id"]] = meta["hash"]
4242

43-
cache.write("@deps.meta.json", json.dumps(old_deps))
43+
cache.write("@deps.meta.json", json_dumps(old_deps))
4444

4545
cache.commit()
4646

misc/diff-cache.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from __future__ import annotations
99

1010
import argparse
11-
import json
1211
import os
1312
import sys
1413
from collections import defaultdict
@@ -17,6 +16,7 @@
1716
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1817

1918
from mypy.metastore import FilesystemMetadataStore, MetadataStore, SqliteMetadataStore
19+
from mypy.util import json_dumps, json_loads
2020

2121

2222
def make_cache(input_dir: str, sqlite: bool) -> MetadataStore:
@@ -33,7 +33,7 @@ def merge_deps(all: dict[str, set[str]], new: dict[str, set[str]]) -> None:
3333

3434
def load(cache: MetadataStore, s: str) -> Any:
3535
data = cache.read(s)
36-
obj = json.loads(data)
36+
obj = json_loads(data)
3737
if s.endswith(".meta.json"):
3838
# For meta files, zero out the mtimes and sort the
3939
# dependencies to avoid spurious conflicts
@@ -73,7 +73,7 @@ def main() -> None:
7373
type_misses: dict[str, int] = defaultdict(int)
7474
type_hits: dict[str, int] = defaultdict(int)
7575

76-
updates: dict[str, str | None] = {}
76+
updates: dict[str, bytes | None] = {}
7777

7878
deps1: dict[str, set[str]] = {}
7979
deps2: dict[str, set[str]] = {}
@@ -96,7 +96,7 @@ def main() -> None:
9696
# so we can produce a much smaller direct diff of them.
9797
if ".deps." not in s:
9898
if obj2 is not None:
99-
updates[s] = json.dumps(obj2)
99+
updates[s] = json_dumps(obj2)
100100
else:
101101
updates[s] = None
102102
elif obj2:
@@ -122,7 +122,7 @@ def main() -> None:
122122
merge_deps(new_deps, root_deps)
123123

124124
new_deps_json = {k: list(v) for k, v in new_deps.items() if v}
125-
updates["@root.deps.json"] = json.dumps(new_deps_json)
125+
updates["@root.deps.json"] = json_dumps(new_deps_json)
126126

127127
# Drop updates to deps.meta.json for size reasons. The diff
128128
# applier will manually fix it up.
@@ -136,8 +136,8 @@ def main() -> None:
136136
print("hits", type_hits)
137137
print("misses", type_misses)
138138

139-
with open(args.output, "w") as f:
140-
json.dump(updates, f)
139+
with open(args.output, "wb") as f:
140+
f.write(json_dumps(updates))
141141

142142

143143
if __name__ == "__main__":

misc/typeshed_patches/0001-Remove-use-of-LiteralString-in-builtins-13743.patch

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
From 3ec9b878d6bbe3fae64a508a62372f10a886406f Mon Sep 17 00:00:00 2001
1+
From b4259edd94188f9e4cc77a22e768eea183a32053 Mon Sep 17 00:00:00 2001
22
From: Shantanu <[email protected]>
33
Date: Mon, 26 Sep 2022 12:55:07 -0700
44
Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
55

66
---
7-
mypy/typeshed/stdlib/builtins.pyi | 95 -------------------------------
8-
1 file changed, 95 deletions(-)
7+
mypy/typeshed/stdlib/builtins.pyi | 100 +-----------------------------
8+
1 file changed, 1 insertion(+), 99 deletions(-)
99

1010
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
11-
index 53e00ec6a..bad3250ef 100644
11+
index 63c53a5f6..d55042b56 100644
1212
--- a/mypy/typeshed/stdlib/builtins.pyi
1313
+++ b/mypy/typeshed/stdlib/builtins.pyi
14-
@@ -61,7 +61,6 @@ from typing import ( # noqa: Y022
14+
@@ -63,7 +63,6 @@ from typing import ( # noqa: Y022
1515
from typing_extensions import ( # noqa: Y023
1616
Concatenate,
1717
Literal,
1818
- LiteralString,
1919
ParamSpec,
2020
Self,
2121
TypeAlias,
22-
@@ -435,31 +434,16 @@ class str(Sequence[str]):
22+
@@ -438,31 +437,16 @@ class str(Sequence[str]):
2323
def __new__(cls, object: object = ...) -> Self: ...
2424
@overload
2525
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
@@ -51,7 +51,7 @@ index 53e00ec6a..bad3250ef 100644
5151
def format(self, *args: object, **kwargs: object) -> str: ...
5252
def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
5353
def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
54-
@@ -475,99 +459,35 @@ class str(Sequence[str]):
54+
@@ -478,99 +462,35 @@ class str(Sequence[str]):
5555
def isspace(self) -> bool: ...
5656
def istitle(self) -> bool: ...
5757
def isupper(self) -> bool: ...
@@ -151,7 +151,7 @@ index 53e00ec6a..bad3250ef 100644
151151
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
152152
@staticmethod
153153
@overload
154-
@@ -578,9 +498,6 @@ class str(Sequence[str]):
154+
@@ -581,39 +501,21 @@ class str(Sequence[str]):
155155
@staticmethod
156156
@overload
157157
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
@@ -161,8 +161,13 @@ index 53e00ec6a..bad3250ef 100644
161161
def __add__(self, value: str, /) -> str: ... # type: ignore[misc]
162162
# Incompatible with Sequence.__contains__
163163
def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]
164-
@@ -589,25 +506,13 @@ class str(Sequence[str]):
165-
def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...
164+
def __eq__(self, value: object, /) -> bool: ...
165+
def __ge__(self, value: str, /) -> bool: ...
166+
- @overload
167+
- def __getitem__(self: LiteralString, key: SupportsIndex | slice, /) -> LiteralString: ...
168+
- @overload
169+
- def __getitem__(self, key: SupportsIndex | slice, /) -> str: ... # type: ignore[misc]
170+
+ def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...
166171
def __gt__(self, value: str, /) -> bool: ...
167172
def __hash__(self) -> int: ...
168173
- @overload
@@ -188,5 +193,5 @@ index 53e00ec6a..bad3250ef 100644
188193
def __getnewargs__(self) -> tuple[str]: ...
189194

190195
--
191-
2.45.2
196+
2.47.0
192197

0 commit comments

Comments
 (0)