Repository navigation
tentative migrate pyright to ty - #6465
benedikt-bartscher wants to merge 56 commits into
Conversation
Merging this PR will not alter performance1 warning
Comparing |
Resolve conflicts from upstream's memo refactor (reflex-dev#6517, promote rx._x.memo to rx.memo): memo implementation moved to reflex_base.components.memo and CustomComponent was removed. Re-apply the ty migration changes onto the new locations: - reflex/experimental/memo.py: take upstream's deprecated alias - reflex_base/components/memo.py: type fn params as FunctionType and add ty:ignore for dynamic __signature__ assignment - tests: drop CustomComponent tests removed upstream; carry ty:ignore comments onto the relocated memo/telemetry tests - pyproject.toml / uv.lock: keep both towncrier (upstream) and ty (HEAD) - pyi_hashes.json: regenerated ty check, ruff, and the unit suite pass.
Conflict resolutions of note: - pyproject.toml: `[tool.pyright]` is replaced by the branch's `[tool.ty.*]` tables; main's new `packages/reflex-ui-shared` exclusion is folded in, and `[tool.check-outdated-deps] backend_pinned` now pins `ty` instead of `pyright`, which is what main's new `scripts/check_outdated_deps.py` reads (the branch's inline `grep -vE` filter in the workflow is gone). - .pre-commit-config.yaml: the repo-wide hook runs `ty check`; main's `tests/type_checking` hook keeps its own id so both stay addressable. - reflex_base logging: main's move from `console` to stdlib `logging` wins in decorator.py, tasks.py and types.py, keeping the branch's `callable_name` for names a `Callable` does not statically have. - vars/base.py: `field()`'s overloads keep main's `FIELD_TYPE` / `Field[FIELD_TYPE]` return types rather than the branch's `Any`; main's `tests/type_checking/fields.py` asserts them. - istate/proxy.py: main's `_dataclass_proxy_namespace` plus the wrapt-stubs cast in `__new__`, which ty needs as well. - scripts/release.py: deleted, as on main. Type checking is clean after converting main's new `pyright: ignore` and `type: ignore` comments to the ty rules ty actually reports.
[Medium impact] The latest change appears safe to merge; no new blocking issue was found. SummaryReplaces Pyright with
Reviews (12) · Last reviewed commit: "Floor reflex-components-core on the sonn..." · Reviewed by Greptile |
`scripts/check_min_deps.py` still shelled out to `pyright`, which this branch removed from the dev dependencies, so every `check-min-deps` job died with `FileNotFoundError: 'pyright'` before checking anything. It now runs `ty check --python <isolated venv> --output-format concise` and diffs the parsed error lines, with the rule severities copied out of the root `[tool.ty.rules]` into the `ty.toml` that `--config-file` supplies, so the isolated runs stay comparable to the repo-wide check. ty resolves more of the older releases than pyright did, so several packages now report deltas against their declared `reflex-base` floors. Those floors are genuinely behind the `field()` signature the components use; raising them is left to a separate change.
Conflict resolutions of note: - pyproject.toml: main's `[tool.pyright] extraPaths` stays dropped; its `packages/reflex-workflow` entry, which the workflow examples import from, becomes `[tool.ty.environment] extra-paths`. - scripts/check_min_deps.py: main's workspace wheelhouse and per-module invocation, run through ty; the per-module test now inspects the ty command. - vars/base.py and state.py: main's descriptor-backed fields and attribute access win; `_update_substate_vars` keeps the branch's `Mapping` parameter, and the mixin copy keeps the `FunctionType` guard on `fget`. - istate/proxy.py: `ImmutableMutableProxy._self_state` stays annotated as `StateProxy`, so main's cast in `_dirty_state` is dropped. - reflex/constants/custom_components.py: deleted, as on main. Type checking is clean after converting main's new `pyright: ignore` and `type: ignore` comments to the ty rules ty actually reports, and ignoring ty's stricter `**` unpacking checks in main's new tests.
Comments Outside DiffThese findings could not be posted inline.
|
Conflicts keep upstream's refactors (proxy class cache, Var.to, redis state writes, file locks, Python 3.11 floor) with the branch's ty changes reapplied on top: pyright ignores dropped, ComputedVar.__get__ takes upstream's `instance: Any` with the branch's `owner: type[BaseState]`, reflex.model keeps SQLModelConfig beside upstream's lazy AsyncSession import. With 3.10 gone, the explicit ty python-version setting is dropped. New ty diagnostics in upstream code are fixed: the wrapt 2.5 wrapper takes an args tuple, the frontend shutdown flag is annotated bool, _cache_per_class names fn through callable_name, and the playground types its chart size dict and checks for a str before the filter membership test. Upstream pyright ignores that ty also reports became ty ignores, and ignores made unused by the fixed-arity EventCallback overloads are gone.
rx.Var.create(1).to(int) is a ToOperation, so the LiteralVar check missed it and get_var_value raised instead of returning 1.
format.py now imports console at module level, which closes an import cycle through log and decorator, so decorator.py imports callable_name where it is used. The new frozenset/set type forms in figure_out_type and the deprecated format_data_editor_column test call get ty ignores like their neighbours.
… check Charts now import callable_name, which reflex-base 0.10.0 lacks. The Var/primitive wrapping moved into _wrap_in_fragment so each path checks Component once.
Older sqlmodel defines SQLModelConfig twice behind IS_PYDANTIC_V2, so calling it fails ty at the minimum versions although it works at runtime.
The lock keeps ty at 0.0.73. The branch lists ty in backend_pinned, so it is bumped on its own cadence; upstream's dependency refresh moved it to 0.0.88, which reports several hundred new diagnostics, among them every EventHandler[...] annotation now as invalid-type-form. The pydantic Field overload is split into optional-first and required overloads like upstream's other object overloads, so an optional pydantic field reads as ObjectVar[Model]; tests/type_checking/fields.py covers it. The restored set literal in figure_out_type and a new ForwardRef test parameter get invalid-type-form ignores, two new pyright ignores that ty flags become ty ignores, and ignores made unused by the optional object field fix are dropped.
…ainst The published reflex-base 0.10.1a1 alpha, from a release branch not merged here, lacks this PR's UnionType overloads of passthrough_event_spec, so the min-deps check resolved to it.
_STORAGE_FEATURE is typed dict[type, FeatureName], so the lookup needs no runtime narrowing.
A computed var whose deps hold both the current-state placeholder and its explicit full name, as add_dependency on its own state produces, kept only one of the two sets, so a dependency map rebuilt on reload stopped refreshing on the other.
The connection toaster builds ToastProps with only some fields, which type-checks only against the sonner that gives the rest None defaults.
Uh oh!
There was an error while loading. Please reload this page.