Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include arbitrary function call in Readme #253

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,16 @@ or type `cell_view.<TAB>` in jupyter/ipython
>>> print(cell_view.b_box)
[[0, 10], [2, 8]]
```

##### Call any SKILL function

```python
>>> ws['plus'](3, 4)
7
```

*equivalent to:*

```lisp
(plus 3 4)
```
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ ignore = [
"PLW1641", "PLW3201",
"PT001", "PT013",
"PTH123",
"Q000",
"S101", "S108", "S310", "S311", "S404",
"T201",
"TCH001", "TCH002", "TCH003",
Expand All @@ -152,6 +151,9 @@ ignore = [
"INP001",
"A001",
]
"*" = [
"Q000",
]

[tool.ruff.lint.pylint]
max-args = 7
Expand Down
19 changes: 16 additions & 3 deletions skillbridge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations

import contextlib
from keyword import iskeyword
from os import chdir
from pathlib import Path
from re import fullmatch, sub
from sys import executable, version_info
from typing import Any

from .client.functions import FunctionCollection, keys
from .client.globals import Globals, GlobalVar
Expand Down Expand Up @@ -42,9 +45,19 @@
loop_var_j = Var('j')


def generate_static_completion() -> None:
from mypy.stubgen import Options, generate_stubs # noqa: PLC0415
def import_stub_gen() -> tuple[Any, Any]:
# the cpython parser wrongly parses a python3.8-valid syntax as invalid
# the newest mypy version uses that parser
# this syntax occurs in the mypy source code
# -> mypy detects a syntax error in its own code base
# this can only be ignored by hiding the import code behind an exec call
scope: dict[str, Any] = {}
exec("from mypy.stubgen import Options, generate_stubs", scope, scope) # noqa: S102
return scope['Options'], scope['generate_stubs']


def generate_static_completion() -> None:
options, generate_stubs = import_stub_gen()
base = Path(__file__).parent.absolute() / 'client'
annotation = base / 'workspace.pyi'

Expand All @@ -53,7 +66,7 @@ def generate_static_completion() -> None:

chdir(base)

o = Options(
o = options(
(version_info.major, version_info.minor),
no_import=True,
doc_dir='',
Expand Down
Loading