Skip to content

Commit

Permalink
Merge pull request #249 from unihd-cag/update-build
Browse files Browse the repository at this point in the history
Update build
  • Loading branch information
TM90 committed Feb 19, 2024
2 parents 9b1ecc3 + 7238df8 commit 87d293a
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 101 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
run: |
pip install -e .
- name: Check with black
- name: Check with ruff format
run: |
pip install black
black . --check
pip install ruff
ruff format
- name: Check with ruff
run: |
Expand Down
70 changes: 66 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@
requires = ["setuptools>=57", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "skillbridge"
authors = [
{name = "Niels Buwen", email = "[email protected]"},
{name = "Tobias Markus", email = "[email protected]"},
]
description = "A seamless Python remote bridge to Cadence's Skill in Virtuoso"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.8"
dependencies = []
urls = {Repository = "https://github.com/unihd-cag/skillbridge"}
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Information Technology",
"Operating System :: POSIX :: Linux",
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
"Topic :: Software Development",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
]
dynamic = ["version"]

[tool.setuptools.dynamic]
version = {attr = "skillbridge.version.__version__"}

[project.optional-dependencies]
dev = [
"pytest",
"pytest-coverage",
"hypothesis",
"mypy",
"ruff>=0.2.1",
]
doc = [
"sphinx"
]

[project.scripts]
skillbridge = "skillbridge.__main__:main"

[tool.setuptools.packages.find]
include = ["skillbridge*"]
namespaces = false

[tool.black]
skip-string-normalization = true
target-version = ["py38"]
Expand Down Expand Up @@ -50,32 +101,39 @@ implicit_reexport = false
strict_equality = true

[tool.ruff]
preview = true
exclude = ["venv", "env", "build"]
line-length = 100
target-version = "py38"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"A003",
"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",
"TRY003", "TRY004", "TRY400",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"ANN",
"ARG001",
Expand All @@ -95,5 +153,9 @@ ignore = [
"A001",
]

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
max-args = 7

[tool.ruff.format]
docstring-code-format = true
quote-style = "preserve"
56 changes: 0 additions & 56 deletions setup.cfg

This file was deleted.

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
6 changes: 2 additions & 4 deletions skillbridge/client/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,10 @@ def filter(self, *args: str, **kwargs: Any) -> LazyList:
return LazyList(self._channel, self._translator, variable)

@overload
def __getitem__(self, item: int) -> RemoteObject:
... # pragma: nocover
def __getitem__(self, item: int) -> RemoteObject: ... # pragma: nocover

@overload
def __getitem__(self, item: slice) -> list[RemoteObject]:
... # pragma: nocover
def __getitem__(self, item: slice) -> list[RemoteObject]: ... # pragma: nocover

def __getitem__(
self,
Expand Down
4 changes: 2 additions & 2 deletions skillbridge/client/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
_open_workspaces: dict[WorkspaceId, Workspace] = {}


logger = getLogger(__file__)
logger = getLogger(__name__)


class _NoWorkspace:
Expand Down 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 87d293a

Please sign in to comment.