Skip to content

Strange intellisense behaviour/getting some redlines #41

@unnamedunknownusername

Description

@unnamedunknownusername

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
#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?

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is neededquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions