Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
8885469 to
2e6aaea
Compare
This comment has been minimized.
This comment has been minimized.
2e6aaea to
27fbf56
Compare
This comment has been minimized.
This comment has been minimized.
|
The mypy_primer hit in dragonchain is a true positive of dragonchain's code. |
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.
Generally, any non-obvious Any needs to be explained. See here. I've noted a few instances below, but there are more.
| def __init__(self, gconfig: Mapping[str, Any] = {}, **options: Any) -> None: ... | ||
| def configure(self, gconfig: Mapping[str, Any] = {}, prefix: str | None = "apscheduler.", **options: Any) -> None: ... |
There was a problem hiding this comment.
As far as I can see, there are a few concrete options, meaning that we should either list there here with their concrete types or just leave options unannotated for now.
There was a problem hiding this comment.
options is now Unpack[_SchedulerOptions], a TypedDict of the six options _configure reads (logger, timezone, jobstore_retry_interval, job_defaults, executors, jobstores), each with the types it converts from. gconfig is Mapping[str, object]: its dotted keys hold the same options.
| @property | ||
| def running(self) -> bool: ... | ||
| # An executor is an apscheduler.executors.base.BaseExecutor or the name of an executor plugin. | ||
| def add_executor(self, executor, alias: str = "default", **executor_opts: Any) -> None: ... |
There was a problem hiding this comment.
executor_opts needs a short explanation for why Any is needed. (Might be something like "options are passed to ...".)
There was a problem hiding this comment.
executor_opts is object now, with a comment: they go to the constructor of the executor plugin that executor names, and an executor instance ignores them. executor itself is BaseExecutor | str, with stubs for apscheduler.executors.base.
| def add_executor(self, executor, alias: str = "default", **executor_opts: Any) -> None: ... | ||
| def remove_executor(self, alias: str, shutdown: bool = True) -> None: ... | ||
| # A job store, or the name of a job store plugin. | ||
| def add_jobstore(self, jobstore: BaseJobStore | str, alias: str = "default", **jobstore_opts: Any) -> None: ... |
There was a problem hiding this comment.
Same here: object, with a comment that they go to the constructor of the job store plugin that jobstore names, and that a job store instance ignores them.
| args: Iterable[Any] | None = None, | ||
| kwargs: Mapping[str, Any] | None = None, |
There was a problem hiding this comment.
Same here for args and kwargs. Probably something like "args and kwargs are passed to func".
There was a problem hiding this comment.
Iterable[object] and Mapping[str, object] now, with the comment "args and kwargs are passed to func when the job runs"; Job.args and Job.kwargs likewise.
27fbf56 to
27739db
Compare
|
Thanks. The tests are removed, and no annotation in the package is |
This comment has been minimized.
This comment has been minimized.
APScheduler 3.11 ships no type information; this adds partial stubs for its scheduler, job, interval trigger, job store and executor bases, and events. Upstream: [the 3.x source](https://github.com/agronholm/apscheduler/tree/3.x/src/apscheduler) and [documentation](https://apscheduler.readthedocs.io/en/3.x/). Written with Claude Code (Claude Opus 5.5).
27739db to
4386794
Compare
|
On mypy_primer's dragonchain hits: the two |
|
Diff from mypy_primer, showing the effect of this PR on open source code: dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/scheduler/background_scheduler.py:28:52: error: Argument 1 to "get_exception_message" has incompatible type "BaseException | None"; expected "Exception" [arg-type]
+ dragonchain/scheduler/background_scheduler.py:29:37: error: Argument 1 to "report_exception" has incompatible type "BaseException | None"; expected "Exception" [arg-type]
+ dragonchain/scheduler/timing_event_utest.py:101:21: error: Module has no attribute "jobstores" [attr-defined]
+ dragonchain/transaction_processor/transaction_processor.py:63:52: error: Argument 1 to "get_exception_message" has incompatible type "BaseException | None"; expected "Exception" [arg-type]
+ dragonchain/transaction_processor/transaction_processor.py:64:37: error: Argument 1 to "report_exception" has incompatible type "BaseException | None"; expected "Exception" [arg-type]
|
Please note that this actually not correct. |
Right. |
Add stubs for APScheduler
APScheduler 3.11 ships no type information; this adds partial stubs for its scheduler, job, interval
trigger, job store and executor bases, and events.
Upstream: the 3.x source and
documentation.
Written with Claude Code (Claude Opus 5.5).