Skip to content

Commit 118746c

Browse files
committed
chore(ci): fix black & pyright issues
1 parent 2cf9892 commit 118746c

File tree

13 files changed

+143
-159
lines changed

13 files changed

+143
-159
lines changed

.vscode/settings.json

+13-10
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
},
99
"[javascript]": {
1010
"editor.codeActionsOnSave": {
11-
"source.fixAll.eslint": true
11+
"source.fixAll.eslint": "explicit"
1212
},
1313
"editor.defaultFormatter": "esbenp.prettier-vscode",
1414
"editor.tabSize": 2
1515
},
1616
"[javascriptreact]": {
1717
"editor.codeActionsOnSave": {
18-
"source.fixAll.eslint": true
18+
"source.fixAll.eslint": "explicit"
1919
},
2020
"editor.defaultFormatter": "esbenp.prettier-vscode",
2121
"editor.tabSize": 2
@@ -48,14 +48,14 @@
4848
},
4949
"[typescript]": {
5050
"editor.codeActionsOnSave": {
51-
"source.fixAll.eslint": true
51+
"source.fixAll.eslint": "explicit"
5252
},
5353
"editor.defaultFormatter": "esbenp.prettier-vscode",
5454
"editor.tabSize": 2
5555
},
5656
"[typescriptreact]": {
5757
"editor.codeActionsOnSave": {
58-
"source.fixAll.eslint": true
58+
"source.fixAll.eslint": "explicit"
5959
},
6060
"editor.defaultFormatter": "esbenp.prettier-vscode",
6161
"editor.tabSize": 2
@@ -83,6 +83,14 @@
8383
"mdx"
8484
],
8585
"black-formatter.args": ["--config", "pyproject.toml"],
86+
"black-formatter.importStrategy": "fromEnvironment",
87+
"python.analysis.typeCheckingMode": "basic",
88+
"python.analysis.diagnosticSeverityOverrides": {
89+
"reportArgumentType": "warning",
90+
"reportOptionalMemberAccess": "warning",
91+
"reportAttributeAccessIssue": "warning",
92+
"reportReturnType": "warning"
93+
},
8694
"python.analysis.diagnosticMode": "workspace",
8795
"python.analysis.include": ["pyprojects/**", "examples/**"],
8896
"python.testing.pytestArgs": [
@@ -92,10 +100,5 @@
92100
"--cov-report=html"
93101
],
94102
"python.testing.unittestEnabled": false,
95-
"python.testing.pytestEnabled": true,
96-
"[javascript][javascriptreact][typescript][typescriptreact]": {
97-
"editor.codeActionsOnSave": {
98-
"source.fixAll.eslint": "explicit"
99-
}
100-
}
103+
"python.testing.pytestEnabled": true
101104
}

pyproject.toml

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
authors = [{ name = "Tony Wu", email = "[email protected]" }]
2+
authors = [{name = "Tony Wu", email = "[email protected]"}]
33
classifiers = ["Private :: Do Not Upload"]
44
dependencies = []
55
name = "monorepo"
@@ -18,7 +18,7 @@ members = ["pyprojects/*"]
1818

1919
[tool.rye]
2020
dev-dependencies = [
21-
"black[jupyter]>=23.7.0",
21+
"black[jupyter]>=24.1.0",
2222
"datamodel-code-generator>=0.22.1",
2323
"fastapi<0.100",
2424
"hatch>=1.7.0",
@@ -53,7 +53,7 @@ _pb2\\.pyi?
5353
| secretnote/proto
5454
"""
5555
line-length = 88
56-
target-versions = ["py38", "py39", "py310"]
56+
target-version = ["py38", "py39", "py310"]
5757

5858
[tool.ruff]
5959
line-length = 88
@@ -65,14 +65,13 @@ src = ["pyprojects/*/src"]
6565

6666
[tool.pyright]
6767
exclude = ["**/node_modules", "**/__pycache__"]
68-
include = ["pyprojects/*/src"]
68+
include = ["pyprojects/**"]
69+
typeCheckingMode = "basic"
6970

70-
reportArgumentType = "information"
71-
reportAttributeAccessIssue = "information"
72-
reportGeneralTypeIssues = "information"
73-
reportIncompatibleMethodOverride = "information"
74-
reportIncompatibleVariableOverride = "information"
75-
reportOptionalMemberAccess = "information"
76-
reportOverlappingOverload = "information"
77-
reportPrivateImportUsage = "information"
78-
reportReturnType = "information"
71+
# https://github.com/microsoft/pylance-release/issues/5207 pyright is out of sync with pylance
72+
# we manually specify certain rules
73+
# this should keep in sync with `python.analysis.diagnosticSeverityOverrides` in .vscode/settings.json
74+
reportArgumentType = "warning"
75+
reportAttributeAccessIssue = "warning"
76+
reportOptionalMemberAccess = "warning"
77+
reportReturnType = "warning"

pyprojects/secretnote/src/secretnote/display/api.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66

77

88
@app.post("/visualize")
9-
async def visualize(data: Visualization) -> None:
10-
...
9+
async def visualize(data: Visualization) -> None: ...

pyprojects/secretnote/src/secretnote/display/parsers/expression.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,14 @@ def _get_parameters(
9696

9797

9898
@overload
99-
def _create_object(obj: SnapshotType, name: Optional[str] = None) -> LocalObject:
100-
...
99+
def _create_object(obj: SnapshotType, name: Optional[str] = None) -> LocalObject: ...
101100

102101

103102
@overload
104103
def _create_object(
105104
obj: RemoteObjectSnapshot,
106105
name: Optional[str] = None,
107-
) -> RemoteObject:
108-
...
106+
) -> RemoteObject: ...
109107

110108

111109
def _create_object(obj, name=None):

pyprojects/secretnote/src/secretnote/display/parsers/graph.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,10 @@ def add_edge(self, edge: GraphEdgeType) -> GraphEdgeType:
149149
return edge
150150

151151
@overload
152-
def create_object_node(self, obj: LocalObject) -> LocalObjectNode:
153-
...
152+
def create_object_node(self, obj: LocalObject) -> LocalObjectNode: ...
154153

155154
@overload
156-
def create_object_node(self, obj: RemoteObject) -> RemoteObjectNode:
157-
...
155+
def create_object_node(self, obj: RemoteObject) -> RemoteObjectNode: ...
158156

159157
def create_object_node(self, obj: ObjectSymbolType):
160158
if isinstance(obj, LocalObject):

pyprojects/secretnote/src/secretnote/formal/locations/utils.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ def __init__(self, world: Dict):
1111
self.world = world
1212

1313
@overload
14-
def __call__(self, kind: Type[PYU], party: str, *parties: str) -> PYU:
15-
...
14+
def __call__(self, kind: Type[PYU], party: str, *parties: str) -> PYU: ...
1615

1716
@overload
18-
def __call__(self, kind: Type[SPU], party: str, *parties: str) -> SPU:
19-
...
17+
def __call__(self, kind: Type[SPU], party: str, *parties: str) -> SPU: ...
2018

2119
@overload
22-
def __call__(self, kind: Type[HEU], party: str, *parties: str) -> HEU:
23-
...
20+
def __call__(self, kind: Type[HEU], party: str, *parties: str) -> HEU: ...
2421

2522
def __call__(self, kind: SupportedDevices, party: str, *parties: str):
2623
if kind is PYU:

pyprojects/secretnote/src/secretnote/instrumentation/exporters.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def parse_span(raw_span: ReadableSpan) -> OTelSpanDict:
5555

5656

5757
class SpanReader(Protocol):
58-
def iter_spans(self) -> Iterable[OTelSpanDict]:
59-
...
58+
def iter_spans(self) -> Iterable[OTelSpanDict]: ...
6059

6160

6261
class InMemorySpanExporter(_InMemorySpanExporter, SpanReader):

pyprojects/secretnote/src/secretnote/instrumentation/models.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,11 @@ class APILevel(IntEnum):
6060
class ObjectTracer(abc.ABC):
6161
@classmethod
6262
@abc.abstractmethod
63-
def typecheck(cls, x) -> bool:
64-
...
63+
def typecheck(cls, x) -> bool: ...
6564

6665
@classmethod
6766
@abc.abstractmethod
68-
def trace(cls, x) -> "SnapshotType":
69-
...
67+
def trace(cls, x) -> "SnapshotType": ...
7068

7169
@classmethod
7270
def tree(cls, x) -> Dict[str, Union[List, Dict]]:

pyprojects/secretnote/src/secretnote/instrumentation/snapshot.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,15 @@ def fingerprint(obj: Any) -> str:
144144

145145

146146
@overload
147-
def hash_digest(obj: CodeType) -> str:
148-
...
147+
def hash_digest(obj: CodeType) -> str: ...
149148

150149

151150
@overload
152-
def hash_digest(obj: Hashable) -> str:
153-
...
151+
def hash_digest(obj: Hashable) -> str: ...
154152

155153

156154
@overload
157-
def hash_digest(obj: Any) -> Optional[str]:
158-
...
155+
def hash_digest(obj: Any) -> Optional[str]: ...
159156

160157

161158
def hash_digest(obj):
@@ -218,13 +215,11 @@ def source_code(obj):
218215

219216

220217
@overload
221-
def source_path(filename: str) -> str:
222-
...
218+
def source_path(filename: str) -> str: ...
223219

224220

225221
@overload
226-
def source_path(filename: None) -> None:
227-
...
222+
def source_path(filename: None) -> None: ...
228223

229224

230225
def source_path(filename: Optional[str]) -> Optional[str]:

pyprojects/secretnote/src/secretnote/server/app.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ def get_extension_package(cls):
4646
return JUPYTER_SERVER_EXTENSION_MODULE
4747

4848
@classmethod
49-
def launch(self, argv=None):
49+
def launch(cls, argv=None):
5050
"""Launch the app with command line arguments."""
5151

5252
if argv is None:
5353
args = sys.argv[1:] # slice out extension config.
5454
else:
5555
args = argv
5656

57-
self.ensure_extension_url(args)
57+
cls.ensure_extension_url(args)
5858

59-
self.launch_instance(
59+
cls.launch_instance(
6060
[
6161
"--ServerApp.token=''",
6262
"--ServerApp.allow_origin=*",
@@ -68,9 +68,9 @@ def launch(self, argv=None):
6868
)
6969

7070
@classmethod
71-
def ensure_extension_url(self, args):
71+
def ensure_extension_url(cls, args):
7272
for arg in args:
7373
if arg.startswith("--mode="):
7474
pathname = arg.split("=")[1]
75-
self.extension_url += pathname
75+
cls.extension_url += pathname
7676
break

pyprojects/secretnote/src/secretnote/utils/pydantic.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,10 @@ class ReferenceMap(ProxiedModel, Mapping):
136136
__root__: Union[List[Reference], Dict[Any, Reference], Tuple[Reference, ...]]
137137

138138
@overload
139-
def __getitem__(self, item: TypedKey[T]) -> T:
140-
...
139+
def __getitem__(self, item: TypedKey[T]) -> T: ...
141140

142141
@overload
143-
def __getitem__(self, item: Any):
144-
...
142+
def __getitem__(self, item: Any): ...
145143

146144
def __getitem__(self, item):
147145
if not isinstance(item, tuple):

0 commit comments

Comments
 (0)