Skip to content

A lot of wrong typing hints? #4999

Closed as not planned
Closed as not planned

Description

@larsblumberg

Describe the bug
Using a LSP server with a Reflex app gives a lot of typing errors although all code is correct.

To Reproduce
Enable a LSP such as pylsp-mypy in a Reflex project.

  • Code/Link to Repo: n/a

Expected behavior
LSP does not show typing errors when Relfex is used correctly.

Screenshots

Image

Specifics (please complete the following information):

  • Python Version: 3.11
  • Reflex Version: 0.7.3
  • OS: Pop_OS

Additional context

Using these LSP dependencies:

[tool.poetry.group.dev.dependencies]
pylsp-mypy = ">=0.7.0"
python-lsp-ruff = ">=2.2.2"
python-lsp-server = ">=1.12.2"

Activity

  1. linear commented on Mar 20, 2025

    @linear
  2. benedikt-bartscher commented on Mar 21, 2025

    @benedikt-bartscher
    Contributor

    The recent reflex updates broke ObjectVar typing again, for the 3rd time :/

    You can mitigate it by annotating your vars with ObjectVar or use your_var.to(ObjectVar).

  3. adhami3310 commented on Mar 21, 2025

    @adhami3310
    Member

    we had __getattr__ defined in Var, which made typing think "oh yea i could do this", but all it did was raise errors, so we thought it would be best to move it into a non-typing context
    as an incident for this, Vars that would get downcasted to ObjectVar now would make a "false" alarm on how they don't have __getattr__
    while we would like for Var (or something similar to it, maybe AutoVar) downcast to ObjectVar automatically, this is a restriction in the python typing system that wasn't resolved, so we don't have options other than to either type things as ObjectVar or require an additional function call, like .guess_type()

  4. adhami3310 commented on Mar 21, 2025

    @adhami3310
    Member

    the relevant ticket for this is python/typing#1273 once again

  5. added
    enhancement
    on May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions