remcohaszing / pywakeonlan

A small python module for wake on lan.
https://pywakeonlan.readthedocs.io
MIT License
281 stars 68 forks source link

Add missing typed marker #27

Closed L1ghtn1ng closed 1 year ago

L1ghtn1ng commented 1 year ago

When running mypy on my code that I have now have type hinted I get the following image Can this be added to fix this error please?

DavidPratt512 commented 1 year ago

Since this library doesn't have type hints at the moment, according to the mypy docs, you can add a # type: ignore to the end of the line to suppress the first error.

Though, in this case, the second error will still be present because (I think) you are using from wakeonlan import * in your code. To suppress that error, add another # type: ignore at the end of the line where you use the send_magic_packet() function.

L1ghtn1ng commented 1 year ago

It does have type hinting it just needs that file to say that it does and then mypy will do it’s thing.

On 27 Nov 2022, at 20:01, David Pratt @.***> wrote:



Since this library doesn't have type hints at the moment, according to the mypy docshttps://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker, you can add a # type: ignore to the end of the line to suppress the first error.

Though, in this case, the second error will still be present because (I think) you are using from wakeonlan import * in your code. To suppress that error, add another # type: ignore at the end of the line where you use the send_magic_packet() function.

— Reply to this email directly, view it on GitHubhttps://github.com/remcohaszing/pywakeonlan/issues/27#issuecomment-1328327905, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA3V2QTX3CDKHD5PZSOIXXLWKO4YRANCNFSM6AAAAAASMUA7EM. You are receiving this because you authored the thread.Message ID: @.***>

DavidPratt512 commented 1 year ago

It does have type hinting

Oh - right. Duh.

Correct me if I'm wrong (very possible), but I think mypy will only check types on PEP 561 compliant packages. This isn't a PEP 561 compliant package. So adding a py.typed file to the root directory of this project is not enough.

What I think is needed is a directory structure like this:

.
├── docs
│   ├── apidocs.rst
│   ├── conf.py
│   ├── index.rst
│   └── readme.rst
├── wakeonlan
│   ├── __init__.py
│   ├── py.typed
│   └── wakeonlan.py
├── LICENSE
├── README.rst
├── poetry.lock
├── pyproject.toml
├── setup.cfg
└── test_wakeonlan.py

(Note the wakeonlan package with py.typed inside it.)

L1ghtn1ng commented 1 year ago

This is what the docs say for mypy image

remcohaszing commented 1 year ago

I don’t use Python a lot anymore, but I do want to provide this feature. I’m not super familiar with types in Python. I was under the impression type annotations would be sufficient, but it appears this was wrong.

What needs to happen to generate the py.typed file? Some poetry hook that runs mypy?

I’ll gladly accept a pull request.

L1ghtn1ng commented 1 year ago

As far as I know, from what I can tell it just needs that file named as that even if it’s blank

Kinda how you you can just have a blank init.py will need to do a bit more digging on it

On 28 Nov 2022, at 10:44, Remco Haszing @.***> wrote:



I don’t use Python a lot anymore, but I do want to provide this feature. I was under the impression type annotations would be sufficient, but it appears this was wrong.

What needs to happen to generate the py.typed file? Some poetry hook that runs mypy?

I’ll gladly accept a pull request.

— Reply to this email directly, view it on GitHubhttps://github.com/remcohaszing/pywakeonlan/issues/27#issuecomment-1328868397, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA3V2QUBLTAYB4NIJZG22ULWKSEJBANCNFSM6AAAAAASMUA7EM. You are receiving this because you authored the thread.Message ID: @.***>

DavidPratt512 commented 1 year ago

Hey all, I opened a draft PR #28. Don't know if I'll have time to contribute to this much more. To test this out, you can do a poetry build and do a pip install dist/wakeonlan......whl.

remcohaszing commented 1 year ago

This is now supported in version 3.0.0.