Skip to content

Commit

Permalink
Lint with new version
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsbuwen committed Feb 19, 2024
1 parent 79d6658 commit 7238df8
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 35 deletions.
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,20 @@ ignore = [
"ANN10", "ANN401",
"B028",
"COM812",
"CPY001",
"D",
"EM101", "EM102",
"FBT001", "FBT002",
"G004",
"ISC001",
"N999",
"PD901",
"PLR0911",
"PLR0911", "PLR6301",
"PLW1641", "PLW3201",
"PT001", "PT013",
"PTH123",
"Q000",
"S101", "S108", "S310", "S311",
"S101", "S108", "S310", "S311", "S404",
"T201",
"TCH001", "TCH002", "TCH003",
"TID252",
Expand Down
32 changes: 16 additions & 16 deletions skillbridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
from .client.workspace import Workspace, current_workspace

__all__ = [
'Workspace',
'Var',
'Function',
'GlobalVar',
'Globals',
'Key',
'LazyList',
'ParseError',
'RemoteObject',
'RemoteTable',
'RemoteVector',
'SkillCode',
'SkillList',
'SkillTuple',
'Symbol',
'Key',
'generate_static_completion',
'Var',
'Workspace',
'current_workspace',
'generate_static_completion',
'keys',
'SkillTuple',
'SkillList',
'SkillCode',
'Function',
'loop_var',
'loop_var_i',
'loop_var_j',
'Globals',
'GlobalVar',
'RemoteTable',
'RemoteVector',
'RemoteObject',
'LazyList',
]

loop_var = Var('i')
Expand All @@ -43,7 +43,7 @@


def generate_static_completion() -> None:
from mypy.stubgen import Options, generate_stubs
from mypy.stubgen import Options, generate_stubs # noqa: PLC0415

base = Path(__file__).parent.absolute() / 'client'
annotation = base / 'workspace.pyi'
Expand Down Expand Up @@ -83,7 +83,7 @@ def generate_static_completion() -> None:
text = sub(r' {4}[a-z][a-zA-Z]+: FunctionCollection\n', '', text)
annotation.write_text(text)

with open(annotation, 'a') as fout:
with open(annotation, 'a', encoding='utf-8') as fout:
for key, value in ws.__dict__.items():
if not isinstance(value, FunctionCollection):
continue
Expand Down
2 changes: 1 addition & 1 deletion skillbridge/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def deprecated_command() -> None: # pragma: no cover


def shell_command(ws_id: str | None, ping: bool) -> None:
import skillbridge
import skillbridge # noqa: PLC0415

variables = {name: getattr(skillbridge, name) for name in dir(skillbridge)}
ws = skillbridge.Workspace.open(ws_id)
Expand Down
6 changes: 4 additions & 2 deletions skillbridge/client/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def create_channel_class() -> type[TcpChannel]:
class WindowsChannel(TcpChannel):
def configure(self, sock: socket) -> None:
try:
from socket import SIO_LOOPBACK_FAST_PATH # type: ignore[attr-defined]
from socket import ( # type: ignore[attr-defined] # noqa: PLC0415
SIO_LOOPBACK_FAST_PATH,
)

sock.ioctl( # type: ignore[attr-defined]
SIO_LOOPBACK_FAST_PATH,
Expand All @@ -206,7 +208,7 @@ def create_address(id_: Any) -> Any:
else:

def create_channel_class() -> type[TcpChannel]:
from socket import AF_UNIX
from socket import AF_UNIX # noqa: PLC0415

class UnixChannel(TcpChannel):
address_family = AF_UNIX
Expand Down
2 changes: 1 addition & 1 deletion skillbridge/client/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class GlobalVar:
__slots__ = 'name', '_channel', '_translator'
__slots__ = '_channel', '_translator', 'name'

def __init__(self, name: str, channel: Channel, translator: Translator) -> None:
self.name = name
Expand Down
12 changes: 6 additions & 6 deletions skillbridge/client/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ class Protocol:


__all__ = [
'Number',
'Symbol',
'Function',
'Key',
'SkillComponent',
'SkillCode',
'Number',
'Skill',
'Function',
'SkillTuple',
'SkillCode',
'SkillComponent',
'SkillList',
'SkillTuple',
'SupportsReprSkill',
'Symbol',
]

Number = Union[int, float]
Expand Down
2 changes: 1 addition & 1 deletion skillbridge/client/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def register(self, function: Callable[..., Any]) -> Function:
name = camel_to_snake(function.__name__)

try:
prefix, rest = name.split('_', maxsplit=1)
prefix, _ = name.split('_', maxsplit=1)
except ValueError:
raise RuntimeError("Function does not have a prefix.") from None

Expand Down
8 changes: 5 additions & 3 deletions skillbridge/server/python_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def read_from_skill(timeout: float | None) -> str:


def create_windows_server_class(single: bool) -> type[BaseServer]:
from socketserver import TCPServer
from socketserver import TCPServer # noqa: PLC0415

class SingleWindowsServer(TCPServer):
request_queue_size = 0
Expand All @@ -49,7 +49,9 @@ def __init__(self, port: int, handler: type[BaseRequestHandler]) -> None:

def server_bind(self) -> None:
try:
from socket import SIO_LOOPBACK_FAST_PATH # type: ignore[attr-defined]
from socket import ( # type: ignore[attr-defined] # noqa: PLC0415
SIO_LOOPBACK_FAST_PATH,
)

self.socket.ioctl( # type: ignore[attr-defined]
SIO_LOOPBACK_FAST_PATH,
Expand All @@ -71,7 +73,7 @@ def data_windows_ready(timeout: float | None) -> bool:


def create_unix_server_class(single: bool) -> type[BaseServer]:
from socketserver import UnixStreamServer
from socketserver import UnixStreamServer # noqa: PLC0415

class SingleUnixServer(UnixStreamServer):
request_queue_size = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def ws() -> Workspace:
else:
break
else:
raise
raise RuntimeError
yield ws

ws.close()
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_warning_is_printed(server, ws):
result = ws.ge.get_edit_cell_view()

assert len(w) == 1
assert w[0].category == UserWarning
assert w[0].category is UserWarning
assert "This is a warning" in str(w[0].message)

assert result == 1234
Expand Down
2 changes: 1 addition & 1 deletion tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from skillbridge import Workspace
from skillbridge.client.channel import Channel
from skillbridge.client.translator import DefaultTranslator
from skillbridge.client.workspace import _open_workspaces
from skillbridge.client.workspace import _open_workspaces # noqa: PLC2701


class DummyChannel(Channel):
Expand Down

0 comments on commit 7238df8

Please sign in to comment.