djapy icon indicating copy to clipboard operation
djapy copied to clipboard

Strange intellisense behaviour/getting some redlines

Open unnamedunknownusername opened this issue 5 months ago • 3 comments

Hi there

Thanks for all the work on this package I really like it over alternatives like Django-Ninja or FastApi

I followed a PR https://github.com/Bishwas-py/djapy/pull/25 and I saw this post Image

I really want to structure my "URL Handler" files like this

ViewHandlerToGetMyBook.py

from django.urls import path

from djapy import Schema
from djapy import djapify


class GetMyBookInput(Schema):
    id: str


class GetMyBookOutput(Schema):
    id: str
    title: str
    yearPublished: int


def GetMyBookHandler(request, data: GetMyBookInput) -> GetMyBookOutput:
    """
    returns a specific book
    """

    result = GetMyBookOutput(
        id=data.id,
        title="MyFirstBook",
        yearPublished=2025,
    )

    return result


GetAllBooksUrlPath = path(
    "getMyBook",
    GetMyBookHandler,
    "get-my-book",
)

i.e. every handler file has

  • an xyzInputSchema which subclasses Schema
  • an xyzOutputSchema which subclasses Schema
  • an xyzHandler which does the logic and takes in the Input and returns the Output
  • a path where the url details are stored. This can then be placed in a DjangoApps/Projects url

I kow it isn't the standard way but I like it because everything to do with a url/handler is in one file and I can easily tweak an input schema if for instance i wanted to request via name and ID.

from the picture I posted above it would seem like this is possible

however when I do this in vscode I get redlines/the following errors

Image

when I hover over path

No overloads for "path" match the provided argumentsPylance

when I hover over the function

No overloads for "path" match the provided argumentsPylance[reportCallIssue](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportCallIssue.md)
conf.pyi(36, 5): Overload 4 is the closest match
Argument of type "(request: Unknown, data: GetMyBookInput) -> GetMyBookOutput" cannot be assigned to parameter "view" of type "tuple[list[URLResolver | URLPattern], str, str]" in function "path"
  "FunctionType" is not assignable to "tuple[list[URLResolver | URLPattern], str, str]"Pylance[reportArgumentType](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportArgumentType.md)

(even if these are just type errors that would be ignored by the intepreter, I still think we probably wouldn't want it to highlight red) Do you know where I could be going wrong?

unnamedunknownusername avatar Aug 08 '25 23:08 unnamedunknownusername

GetMyBookHandler is not wrapped by djapify right?

Bishwas-py avatar Aug 24 '25 02:08 Bishwas-py

@Bishwas-py i can help. Can it be assigned to me?

Prashidha0O1 avatar Oct 07 '25 11:10 Prashidha0O1

@Prashidha0O1 yeah sure.

Bishwas-py avatar Oct 07 '25 12:10 Bishwas-py