Skip to content

Commit c7f5c91

Browse files
committed
chore: py3.8 setting for pyright, CamelCase type alias
1 parent 6fdef4b commit c7f5c91

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

juju/client/connection.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
from juju.utils import IdQueue
2424
from juju.version import CLIENT_VERSION
2525

26-
from .facade import _JSON, _RICH_JSON, TypeEncoder
26+
from .facade import TypeEncoder, _Json, _RichJson
2727
from .facade_versions import client_facade_versions, known_unsupported_facades
2828

29-
SPECIFIED_FACADES: TypeAlias = "dict[str, dict[Literal['versions'], Sequence[int]]]"
29+
SpecifiedFacades: TypeAlias = "dict[str, dict[Literal['versions'], Sequence[int]]]"
3030
_WebSocket: TypeAlias = "websockets.legacy.client.WebSocketClientProtocol"
3131

3232
LEVELS = ["TRACE", "DEBUG", "INFO", "WARNING", "ERROR"]
@@ -140,7 +140,7 @@ async def connect(
140140
max_frame_size: int | None = None,
141141
retries=3,
142142
retry_backoff=10,
143-
specified_facades: SPECIFIED_FACADES | None = None,
143+
specified_facades: SpecifiedFacades | None = None,
144144
proxy=None,
145145
debug_log_conn=None,
146146
debug_log_params={},
@@ -542,17 +542,17 @@ async def _do_ping():
542542

543543
@overload
544544
async def rpc(
545-
self, msg: dict[str, _JSON], encoder: None = None
546-
) -> dict[str, _JSON]: ...
545+
self, msg: dict[str, _Json], encoder: None = None
546+
) -> dict[str, _Json]: ...
547547

548548
@overload
549549
async def rpc(
550-
self, msg: dict[str, _RICH_JSON], encoder: TypeEncoder
551-
) -> dict[str, _JSON]: ...
550+
self, msg: dict[str, _RichJson], encoder: TypeEncoder
551+
) -> dict[str, _Json]: ...
552552

553553
async def rpc(
554554
self, msg: dict[str, Any], encoder: json.JSONEncoder | None = None
555-
) -> dict[str, Any]:
555+
) -> dict[str, _Json]:
556556
"""Make an RPC to the API. The message is encoded as JSON
557557
using the given encoder if any.
558558
:param msg: Parameters for the call (will be encoded as JSON).

juju/client/facade.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
from . import codegen
2424

2525
# Plain JSON, what is received from Juju
26-
_JSON_LEAF: TypeAlias = "None | bool | int | float | str"
27-
_JSON: TypeAlias = "_JSON_LEAF|list[_JSON]|dict[str, _JSON]"
26+
_JsonLeaf: TypeAlias = "None | bool | int | float | str"
27+
_Json: TypeAlias = "_JsonLeaf|list[_Json]|dict[str, _Json]"
2828

2929
# Type-enriched JSON, what can be sent to Juju
30-
_RICH_LEAF: TypeAlias = "_JSON_LEAF|Type"
31-
_RICH_JSON: TypeAlias = "_RICH_LEAF|list[_RICH_JSON]|dict[str, _RICH_JSON]"
30+
_RichLeaf: TypeAlias = "_JsonLeaf|Type"
31+
_RichJson: TypeAlias = "_RichLeaf|list[_RichJson]|dict[str, _RichJson]"
3232

3333
_marker = object()
3434

@@ -644,7 +644,7 @@ class {name}Facade(Type):
644644

645645

646646
class TypeEncoder(json.JSONEncoder):
647-
def default(self, obj: _RICH_JSON) -> _JSON:
647+
def default(self, obj: _RichJson) -> _Json:
648648
if isinstance(obj, Type):
649649
return obj.serialize()
650650
return json.JSONEncoder.default(self, obj)
@@ -663,7 +663,7 @@ def __eq__(self, other):
663663

664664
return self.__dict__ == other.__dict__
665665

666-
async def rpc(self, msg: dict[str, _RICH_JSON]) -> _JSON:
666+
async def rpc(self, msg: dict[str, _RichJson]) -> _Json:
667667
result = await self.connection.rpc(msg, encoder=TypeEncoder)
668668
return result
669669

@@ -714,7 +714,7 @@ def _parse_nested_list_entry(expr, result_dict):
714714
return cls(**d)
715715
return None
716716

717-
def serialize(self) -> dict[str, _JSON]:
717+
def serialize(self) -> dict[str, _Json]:
718718
d = {}
719719
for attr, tgt in self._toSchema.items():
720720
d[tgt] = getattr(self, attr)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ ignore = [
211211

212212
[tool.pyright]
213213
# These are tentative
214-
# include = ["**/*.py"]
215-
pythonVersion = "3.10"
214+
include = ["**/*.py"]
215+
pythonVersion = "3.8"
216216
typeCheckingMode = "strict"
217217
useLibraryCodeForTypes = true
218218
reportGeneralTypeIssues = true

0 commit comments

Comments
 (0)