Skip to content

Commit

Permalink
Merge pull request #253 from unihd-cag/readme-any-call
Browse files Browse the repository at this point in the history
Include arbitrary function call in Readme
  • Loading branch information
TM90 committed Apr 11, 2024
2 parents 0277731 + a4fd390 commit 7884247
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
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

0 comments on commit 7884247

Please sign in to comment.