Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
bd82b0e to
9539cf2
Compare
This comment has been minimized.
This comment has been minimized.
e430b18 to
9e0e63a
Compare
This comment has been minimized.
This comment has been minimized.
srittau
left a comment
There was a problem hiding this comment.
Please remove the tests. In typeshed, we only add regression tests for functions and classes which are known to have caused complex problems in the past, or where stubs are difficult to get right. 100% test coverage for typeshed is neither necessary nor desirable, as it would lead to code duplication.
See tests/REGRESSION.md for more information.
| done_message: _T | ||
| done: bool | ||
| error: bytes | None | ||
| def __init__(self, *args: Any, command, **kwargs: Any) -> None: ... |
There was a problem hiding this comment.
This should use the concrete arguments that are accepted. Alternatively, leave the *args and **kwargs unannotated for now.
There was a problem hiding this comment.
It now takes the rows as list's optional positional iterable and a keyword-only command: CommandSentence, with stubs for routeros_api.sentence.
| def get_mikrotik_value(self, arg: Any, /) -> bytes: ... | ||
| def get_python_value(self, bytes: bytes, /) -> Any: ... |
There was a problem hiding this comment.
We need a short comment why Any is used here or what the possible values are.
There was a problem hiding this comment.
_Field is now generic in what a field encodes and decodes, _Field[_In, _Out], and routeros_api.api_structure has stubs, each field class with its types (StringField encodes and decodes str, IntegerField encodes any value through str() and decodes int, and so on). RouterOsResource is generic over its structure's _In and _Out, and get_resource() without a structure gives RouterOsResource[str, str].
| def get(self, **kwargs: Any) -> AsynchronousResponse[dict[str, Any]]: ... | ||
| def get_async(self, **kwargs: Any) -> _ResponsePromise: ... | ||
| def detailed_get(self, **kwargs: Any) -> AsynchronousResponse[dict[str, Any]]: ... | ||
| def detailed_get_async(self, **kwargs: Any) -> _ResponsePromise: ... | ||
| def set(self, **kwargs: Any) -> AsynchronousResponse[dict[str, Any]]: ... | ||
| # The runtime's set_async calls the synchronous call, so it returns the reply itself. | ||
| def set_async(self, **kwargs: Any) -> AsynchronousResponse[dict[str, Any]]: ... | ||
| def add(self, **kwargs: Any) -> AsynchronousResponse[dict[str, Any]]: ... | ||
| def add_async(self, **kwargs: Any) -> _ResponsePromise: ... | ||
| def remove(self, **kwargs: Any) -> AsynchronousResponse[dict[str, Any]]: ... | ||
| def remove_async(self, **kwargs: Any) -> _ResponsePromise: ... |
There was a problem hiding this comment.
I assume that the arguments here are not arbitrary? In that case it's best to either use the actually accepted arguments or just leave the kwargs arguments unannotated for now. Otherwise, we need a comment explaining the situation.
There was a problem hiding this comment.
Right, they aren't arbitrary. A binary resource's get variants filter by them, so they take bytes | str; set, add and remove send them as arguments, so they take bytes | str | None, None sending the attribute without a value. Its rows are dict[str, bytes]. A typed resource's take its structure's _In, and its rows are dict[str, _Out]; since the runtime's methods accept only what the fields encode, unlike the binary resource's they inherit, they override them with # type: ignore[override].
9e0e63a to
7fe5e05
Compare
|
Thanks. The tests are removed, and no annotation in the package is |
This comment has been minimized.
This comment has been minimized.
RouterOS-api 0.21 ships no type information; this adds partial stubs for its connection pool, API, resources, field structures, queries and exceptions. Upstream: [the source](https://github.com/socialwifi/RouterOS-api/tree/master/routeros_api) and [its README](https://github.com/socialwifi/RouterOS-api#readme). Written with Claude Code (Claude Opus 5.5).
7fe5e05 to
1a84370
Compare
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
I'm sorry, but I can't review the changes, since this was force pushed, against our policy in CONTRIBUTING.md. |
|
Sorry. I wanted a clean commit history. Should I open another PR? |
Add stubs for RouterOS-api
RouterOS-api 0.21 ships no type information; this adds partial stubs for its connection pool, API,
resources, field structures, queries and exceptions.
Upstream: the source and its
README.
Written with Claude Code (Claude Opus 5.5).