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

PythonStandalone Package 0.29.9 stubs errors #1942

Closed
sebastian-goeldi opened this issue Dec 2, 2024 · 5 comments · Fixed by #1943
Closed

PythonStandalone Package 0.29.9 stubs errors #1942

sebastian-goeldi opened this issue Dec 2, 2024 · 5 comments · Fixed by #1943
Assignees
Milestone

Comments

@sebastian-goeldi
Copy link
Contributor

sebastian-goeldi commented Dec 2, 2024

Hi Matthias,

I think my request for the Point.move(d) confused your autogeneration script for the stubs 🫣

In the dbcode.pyi at line 704 there is a syntax error:

    @overload
    def moved(self, dx, 0: int, dy: Optional[int] = ...) -> Box:
        r"""
        @brief Moves the box by a certain distance

        This is a convenience method which takes two values instead of a Point object.
        This method has been introduced in version 0.23.

        @return The moved box.
        """
        ...

The dx, 0: int, should be dx: int = 0 I think. Also, I don't think dy: Optional[int] = ... is valid, I would assume it should be moved(dx: int = 0, dy: Optional[int] = None)

Hopefully this is just some minor tweak to fix it.

If you would want help with this, as always, I'd be happy to help.

Best,
Sebastian

(mypy found that error when I tried to type check kfactory as pre-commit 😄 )

klayoutmatthias pushed a commit that referenced this issue Dec 2, 2024
…faults for Box#enlarge and Box#enlarged (bonus)
@klayoutmatthias klayoutmatthias self-assigned this Dec 2, 2024
@klayoutmatthias klayoutmatthias added this to the 0.29.10 milestone Dec 2, 2024
@klayoutmatthias
Copy link
Collaborator

Ah, well that was a stupid typo that was not covered by tests :(

But as a bonus I added defaults for "Box#enlarge" and "Box#enlarged" which makes a lot of sense to me:

box.enlarge(dx = 17)

@klayoutmatthias klayoutmatthias linked a pull request Dec 2, 2024 that will close this issue
@klayoutmatthias
Copy link
Collaborator

Sorry, did not want to close this issue. It happened automatically when I merged the PR.

One question: is there an easy way to test .pyi files? I mean in a sense of syntax correctness.

Matthias

@klayoutmatthias
Copy link
Collaborator

Oh, i guess I found it:

python3 -m mypy.stubtest klayout.dbcore

If does not give syntax errors anymore, but a lot of warnings - mainly because it does not understand how the overload inference works inside KLayout ...

Matthias

@sebastian-goeldi
Copy link
Contributor Author

I think so. You can install the package with python and install mypy and then runn mypy -p klayout

So python -m pip install klayout mypy; mypy -p klayout should do the trick.

mypy is a static type checker and will check all the type hints for correctness. Similar to pylance etc

@sebastian-goeldi
Copy link
Contributor Author

This works (probably also works with stubtests):

mypy -p klayout --disable-error-code overload-cannot-match --disable-error-code no-untyped-def --disable-error-code no-untyped-call --disable-error-code misc --disable-error-code attr-defined --disable-error-code unused-ignore --disable-error-code override --disable-error-code name-defined --disable-error-code no-redef --disable-error-code import-not-found --disable-error-code assignment

Might be worth to fix some of the errors (like unused ignore redef etc, or at least to have a look at them and then use ignore commands selectively)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants