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

Update network.pyi a bit #296

Merged
merged 8 commits into from
Jul 23, 2024
32 changes: 16 additions & 16 deletions typehints/micropython/network.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ __license__ = "MIT https://opensource.org/licenses/MIT (as used by MicroPython).
__version__ = "7.3.0" # Version set by https://github.com/hlovatt/tag2ver

from abc import abstractmethod
from typing import Protocol, Callable, overload, Any, ClassVar, Final, NoReturn
from typing import Protocol, Callable, overload, Any, ClassVar, Final

import pyb

@overload
def country(code: str, /) -> NoReturn | str:
def country(code: str, /) -> str:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not return value if a parameter is provided

>>> import network
>>> print(network.country())
XX
>>> print(network.country('FI'))
None
>>> print(network.country())
FI
>>> 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nothing is returned, then the return type is None. NoReturn means the function always raises an exception or aborts the program execution.

"""
Get or set the two-letter ISO 3166-1 Alpha-2 country code to be used for
radio compliance.
Expand All @@ -63,7 +63,7 @@ def country(code: str, /) -> NoReturn | str:
The default code ``"XX"`` represents the "worldwide" region.
"""

def hostname(self, name: str) -> NoReturn | str:
def hostname(self, name: str) -> str:
"""Get or set the hostname that will identify this device on the network. It will
elmot marked this conversation as resolved.
Show resolved Hide resolved
be used by all interfaces.

Expand Down Expand Up @@ -98,39 +98,39 @@ MODE_11G: Final[int] = ...
MODE_11N: Final[int] = ...
"""IEEE 802.11n"""

STA_IF:int = 0
STA_IF: int = 0
"""station interface"""

AP_IF:int = 1
AP_IF: int = 1
"""access point interface"""

STAT_IDLE:int = 0
STAT_IDLE: int = 0
"""no connection and no activity"""

STAT_CONNECTING:int = 1
STAT_CONNECTING: int = 1
"""connecting in progress"""

STAT_WRONG_PASSWORD:int = 2
STAT_WRONG_PASSWORD: int = 2
"""failed due to incorrect password"""

STAT_NO_AP_FOUND:int = 3
STAT_NO_AP_FOUND: int = 3
"""failed because no access point replied"""

STAT_CONNECT_FAIL:int = 4
STAT_CONNECT_FAIL: int = 4
"""failed due to other problems"""

STAT_GOT_IP:int = 5
STAT_GOT_IP: int = 5
"""connection successful"""

AUTH_OPEN:int = 0
AUTH_OPEN: int = 0

AUTH_WEP:int = 1
AUTH_WEP: int = 1

AUTH_WPA_PSK:int = 2
AUTH_WPA_PSK: int = 2

AUTH_WPA2_PSK:int = 3
AUTH_WPA2_PSK: int = 3

AUTH_WPA_WPA2_PSK:int = 4
AUTH_WPA_WPA2_PSK: int = 4

@overload
def phy_mode(self) -> int:
Expand Down