Skip to content

enhance type checker #36288

Open
Open

Description

@asukaminato0721

enable

[errors]
implicit-any-parameter = "error"

or

preset = "strict"

in type checker

Activity

  1. asukaminato0721 commented on May 18, 2026

    @asukaminato0721
    ContributorAuthor

    @dosu how to do it

  2. dosubot commented on May 18, 2026

    @dosubot

    The repo currently has Pyright configured in dify-agent/pyproject.toml [1] and MyPy as a dev dependency in api/pyproject.toml [2] but without an explicit [tool.mypy] section.

    To enable stricter type checking:

    For Pyright (dify-agent/pyproject.toml) — add typeCheckingMode or specific error rules:

    [tool.pyright]
    include = ["src", "examples", "tests"]
    pythonVersion = "3.12"
    # Option 1: strict preset
    typeCheckingMode = "strict"
    
    # Option 2: granular control (basedpyright style)
    [tool.pyright.errors]
    implicit-any-parameter = "error"

    For the API (api/pyproject.toml) — add a new MyPy config section:

    [tool.mypy]
    python_version = "3.12"
    strict = true

    Since enabling strict mode will likely surface many existing type errors across the codebase, a common approach is to:

    1. Start by enabling strict checks on a subset of directories (e.g., new modules only).
    2. Gradually expand coverage, or use per-file overrides / # type: ignore to suppress known issues temporarily.
    3. Add the type checker to CI so regressions are caught.

    Would you like me to look into what CI checks are currently configured for type checking, or estimate how many errors strict mode would surface?

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

  3. asukaminato0721 commented on May 18, 2026

    @asukaminato0721
    ContributorAuthor

    @dosu no, use pyrefly

  4. dosubot commented on May 18, 2026

    @dosubot

    To use Pyrefly (Facebook's fast Python type checker) with strict settings, you'd add a [tool.pyrefly] section to your pyproject.toml (e.g., api/pyproject.toml):

    [tool.pyrefly]
    project-includes = ["src"]  # adjust to your source directories
    python-version = "3.12"
    preset = "strict"

    The "strict" preset automatically enables [1]:

    • strict-callable-subtyping = true
    • implicit-any errors (covers all implicit-Any sub-kinds, including implicit-any-parameter)
    • missing-override-decorator errors
    • unused-ignore errors

    If you want more granular control instead of the full preset, you can configure individual error codes:

    [tool.pyrefly]
    project-includes = ["src"]
    python-version = "3.12"
    
    [tool.pyrefly.errors]
    implicit-any = "error"   # or target a specific sub-kind

    To run it:

    pip install pyrefly
    pyrefly check

    You can also use a baseline file to suppress existing errors and only enforce strict checking on new code going forward:

    pyrefly check --baseline="pyrefly-baseline.json" --update-baseline

    Then subsequent runs will only report newly introduced errors [1].

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  5. added
    no-issue-activityIssue has not had recent activity and may be closed automatically.
    and removed on Sep 4, 2026
  6. removed
    no-issue-activityIssue has not had recent activity and may be closed automatically.
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions