Skip to content

some new type errors #44038

Open
Open

Description

@asukaminato0721
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
Warning: `AgentAppNotPublishedError` is already caught earlier in this `try` statement, so it never matches here
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
Warning: `JSONDecodeError` is already caught earlier in this `try` statement, so it never matches here
Warning: `JSONDecodeError` is already caught earlier in this `try` statement, so it never matches here
Warning: `JSONDecodeError` is already caught earlier in this `try` statement, so it never matches here
Warning: `UnicodeDecodeError` is already caught earlier in this `try` statement, so it never matches here
Warning: `JSONDecodeError` is already caught earlier in this `try` statement, so it never matches here
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
Warning: This code is unreachable
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
Warning: This code is unreachable
Warning: This code is unreachable
Warning: `DocumentIndexingError` is already caught earlier in this `try` statement, so it never matches here
Warning: `ValidationError` is already caught earlier in this `try` statement, so it never matches here
 INFO Checking project configured at `/home/runner/work/dify/dify/api/tests/unit_tests/pyrefly.toml`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> @_` in function `unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> @_` in function `unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`
Error: Argument `(ParamSpec(Unknown)) -> Unknown` is not assignable to parameter `func` with type `(...) -> Any` in function `inspect.unwrap`

@dosu how to fix

Activity

  1. dosubot commented on Oct 14, 2026

    @dosubot

    I’d handle these in two groups: redundant exception catches, and unresolved decorator typing at the unwrap boundary. The excerpt omits filenames and line numbers, so I can suggest the fix patterns, but not map all ten errors to exact call sites. [1]

    1. Exception warnings: remove redundant subclasses from an exception tuple when they receive the same handling. For example, api/controllers/console/app/workflow.py has:

      except (ValueError, ValidationError):

      Since Pydantic’s ValidationError is a ValueError, this can become except ValueError:. If separate handlers intentionally produce different responses, put the specific exception first instead of deleting it. Python uses the first matching handler. Apply the same reasoning to JSONDecodeError and UnicodeDecodeError under ValueError. [2]

      Don’t blanket-delete the domain-error handlers: the web completion handler, for example, translates AgentAppNotPublishedError into a specific API error before the generic catches. Check the earlier handler and inheritance at each reported location. [3]

    2. unwrap errors: these suggest Pyrefly hasn’t resolved the decorated callable’s ParamSpec. A targeted workaround to try in the tests is casting the input to unwrap, not only its result:

      import inspect
      from collections.abc import Callable
      from typing import cast
      
      _audio_post = inspect.unwrap(
          cast(Callable[..., object], AudioApi.post)
      )

      This example replaces an existing inspect.unwrap(AudioApi.post) call. Keep the cast at the test boundary rather than weakening production decorator types. The session decorator intentionally removes the injected Session from the public signature, while these tests unwrap it to pass a session explicitly. [4] [5]

    Recheck with make type-check from the repository root. I can’t run Pyrefly here, so the cast needs verification with your checker version. Please include the diagnostic filenames/line numbers and Pyrefly version, especially for the standalone “This code is unreachable” warnings. [6]

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

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

    review: highghfind author score; see https://ghfind.com

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions