Skip to content

Commit

Permalink
chore(ci): fix black & pyright issues (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywu6 authored Feb 2, 2024
1 parent 2cf9892 commit 7bf055c
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 159 deletions.
23 changes: 13 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
},
"[javascript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[javascriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
Expand Down Expand Up @@ -48,14 +48,14 @@
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
Expand Down Expand Up @@ -83,6 +83,14 @@
"mdx"
],
"black-formatter.args": ["--config", "pyproject.toml"],
"black-formatter.importStrategy": "fromEnvironment",
"python.analysis.typeCheckingMode": "basic",
"python.analysis.diagnosticSeverityOverrides": {
"reportArgumentType": "warning",
"reportOptionalMemberAccess": "warning",
"reportAttributeAccessIssue": "warning",
"reportReturnType": "warning"
},
"python.analysis.diagnosticMode": "workspace",
"python.analysis.include": ["pyprojects/**", "examples/**"],
"python.testing.pytestArgs": [
Expand All @@ -92,10 +100,5 @@
"--cov-report=html"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[javascript][javascriptreact][typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
"python.testing.pytestEnabled": true
}
25 changes: 12 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
authors = [{ name = "Tony Wu", email = "tonywu6@protonmail.com" }]
authors = [{name = "Tony Wu", email = "tonywu6@protonmail.com"}]
classifiers = ["Private :: Do Not Upload"]
dependencies = []
name = "monorepo"
Expand All @@ -18,7 +18,7 @@ members = ["pyprojects/*"]

[tool.rye]
dev-dependencies = [
"black[jupyter]>=23.7.0",
"black[jupyter]>=24.1.0",
"datamodel-code-generator>=0.22.1",
"fastapi<0.100",
"hatch>=1.7.0",
Expand Down Expand Up @@ -53,7 +53,7 @@ _pb2\\.pyi?
| secretnote/proto
"""
line-length = 88
target-versions = ["py38", "py39", "py310"]
target-version = ["py38", "py39", "py310"]

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

[tool.pyright]
exclude = ["**/node_modules", "**/__pycache__"]
include = ["pyprojects/*/src"]
include = ["pyprojects/**"]
typeCheckingMode = "basic"

reportArgumentType = "information"
reportAttributeAccessIssue = "information"
reportGeneralTypeIssues = "information"
reportIncompatibleMethodOverride = "information"
reportIncompatibleVariableOverride = "information"
reportOptionalMemberAccess = "information"
reportOverlappingOverload = "information"
reportPrivateImportUsage = "information"
reportReturnType = "information"
# https://github.com/microsoft/pylance-release/issues/5207 pyright is out of sync with pylance
# we manually specify certain rules
# this should keep in sync with `python.analysis.diagnosticSeverityOverrides` in .vscode/settings.json
reportArgumentType = "warning"
reportAttributeAccessIssue = "warning"
reportOptionalMemberAccess = "warning"
reportReturnType = "warning"
3 changes: 1 addition & 2 deletions pyprojects/secretnote/src/secretnote/display/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@


@app.post("/visualize")
async def visualize(data: Visualization) -> None:
...
async def visualize(data: Visualization) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,14 @@ def _get_parameters(


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


@overload
def _create_object(
obj: RemoteObjectSnapshot,
name: Optional[str] = None,
) -> RemoteObject:
...
) -> RemoteObject: ...


def _create_object(obj, name=None):
Expand Down
6 changes: 2 additions & 4 deletions pyprojects/secretnote/src/secretnote/display/parsers/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,10 @@ def add_edge(self, edge: GraphEdgeType) -> GraphEdgeType:
return edge

@overload
def create_object_node(self, obj: LocalObject) -> LocalObjectNode:
...
def create_object_node(self, obj: LocalObject) -> LocalObjectNode: ...

@overload
def create_object_node(self, obj: RemoteObject) -> RemoteObjectNode:
...
def create_object_node(self, obj: RemoteObject) -> RemoteObjectNode: ...

def create_object_node(self, obj: ObjectSymbolType):
if isinstance(obj, LocalObject):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ def __init__(self, world: Dict):
self.world = world

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

@overload
def __call__(self, kind: Type[SPU], party: str, *parties: str) -> SPU:
...
def __call__(self, kind: Type[SPU], party: str, *parties: str) -> SPU: ...

@overload
def __call__(self, kind: Type[HEU], party: str, *parties: str) -> HEU:
...
def __call__(self, kind: Type[HEU], party: str, *parties: str) -> HEU: ...

def __call__(self, kind: SupportedDevices, party: str, *parties: str):
if kind is PYU:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def parse_span(raw_span: ReadableSpan) -> OTelSpanDict:


class SpanReader(Protocol):
def iter_spans(self) -> Iterable[OTelSpanDict]:
...
def iter_spans(self) -> Iterable[OTelSpanDict]: ...


class InMemorySpanExporter(_InMemorySpanExporter, SpanReader):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ class APILevel(IntEnum):
class ObjectTracer(abc.ABC):
@classmethod
@abc.abstractmethod
def typecheck(cls, x) -> bool:
...
def typecheck(cls, x) -> bool: ...

@classmethod
@abc.abstractmethod
def trace(cls, x) -> "SnapshotType":
...
def trace(cls, x) -> "SnapshotType": ...

@classmethod
def tree(cls, x) -> Dict[str, Union[List, Dict]]:
Expand Down
15 changes: 5 additions & 10 deletions pyprojects/secretnote/src/secretnote/instrumentation/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,15 @@ def fingerprint(obj: Any) -> str:


@overload
def hash_digest(obj: CodeType) -> str:
...
def hash_digest(obj: CodeType) -> str: ...


@overload
def hash_digest(obj: Hashable) -> str:
...
def hash_digest(obj: Hashable) -> str: ...


@overload
def hash_digest(obj: Any) -> Optional[str]:
...
def hash_digest(obj: Any) -> Optional[str]: ...


def hash_digest(obj):
Expand Down Expand Up @@ -218,13 +215,11 @@ def source_code(obj):


@overload
def source_path(filename: str) -> str:
...
def source_path(filename: str) -> str: ...


@overload
def source_path(filename: None) -> None:
...
def source_path(filename: None) -> None: ...


def source_path(filename: Optional[str]) -> Optional[str]:
Expand Down
10 changes: 5 additions & 5 deletions pyprojects/secretnote/src/secretnote/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def get_extension_package(cls):
return JUPYTER_SERVER_EXTENSION_MODULE

@classmethod
def launch(self, argv=None):
def launch(cls, argv=None):
"""Launch the app with command line arguments."""

if argv is None:
args = sys.argv[1:] # slice out extension config.
else:
args = argv

self.ensure_extension_url(args)
cls.ensure_extension_url(args)

self.launch_instance(
cls.launch_instance(
[
"--ServerApp.token=''",
"--ServerApp.allow_origin=*",
Expand All @@ -68,9 +68,9 @@ def launch(self, argv=None):
)

@classmethod
def ensure_extension_url(self, args):
def ensure_extension_url(cls, args):
for arg in args:
if arg.startswith("--mode="):
pathname = arg.split("=")[1]
self.extension_url += pathname
cls.extension_url += pathname
break
6 changes: 2 additions & 4 deletions pyprojects/secretnote/src/secretnote/utils/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,10 @@ class ReferenceMap(ProxiedModel, Mapping):
__root__: Union[List[Reference], Dict[Any, Reference], Tuple[Reference, ...]]

@overload
def __getitem__(self, item: TypedKey[T]) -> T:
...
def __getitem__(self, item: TypedKey[T]) -> T: ...

@overload
def __getitem__(self, item: Any):
...
def __getitem__(self, item: Any): ...

def __getitem__(self, item):
if not isinstance(item, tuple):
Expand Down
Loading

0 comments on commit 7bf055c

Please sign in to comment.