Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(debugger): passing debugger to app #3967

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

oek1ng
Copy link
Contributor

@oek1ng oek1ng commented Jan 23, 2025

Description

Passing debugger_module variable to app

  • Added type for pdb-like module, which supports post_mortem method
  • Added debugger test app
  • Added doc

Closes

#3949

@oek1ng oek1ng requested review from a team as code owners January 23, 2025 08:01
@github-actions github-actions bot added area/docs This PR involves changes to the documentation area/private-api This PR involves changes to the privatized API area/types This PR involves changes to the custom types size: small pr/external Triage Required 🏥 This requires triage labels Jan 23, 2025
@oek1ng oek1ng changed the title Passing debugger to app feat(debugger): passing debugger to app Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.35%. Comparing base (f2da7ed) to head (0dfd519).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3967   +/-   ##
=======================================
  Coverage   98.34%   98.35%           
=======================================
  Files         347      348    +1     
  Lines       15743    15793   +50     
  Branches     1740     1745    +5     
=======================================
+ Hits        15483    15533   +50     
  Misses        124      124           
  Partials      136      136           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

) -> Optional[NoReturn]: ...


Debugger: TypeAlias = Union[ModuleType, PDBProtocol, IPDBProtocol, PDBRProtocol, PUDBProtocol]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure either but the tying pros here will kmow _)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just have the post_mortem as

@staticmethod
def post_mortem(
    traceback: TracebackType | None = None,
    *args: Any,
    **kwargs: Any,
) -> Any: ...

instead of an exact match for every single one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just have the post_mortem as

@staticmethod
def post_mortem(
    traceback: TracebackType | None = None,
    *args: Any,
    **kwargs: Any,
) -> Any: ...

instead of an exact match for every single one?

thought about it, these methods have different signatures, and I don't like "Any" much, maybe your solution is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@provinzkraut your solution works fine, should i change it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please

got u

@github-actions github-actions bot added area/dependencies This PR involves changes to the dependencies and removed size: small labels Jan 23, 2025
@oek1ng
Copy link
Contributor Author

oek1ng commented Jan 26, 2025

@sobolevn I'd like if you review me

Copy link
Contributor

@euri10 euri10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor comments on my side, though I wasnt able to be sent into pdb on an exception, is it working or im doing something stupid ?

using this app:

import pdb

import uvicorn

from litestar import Litestar, get


@get("/")
async def exc() -> str:
    1 / 0
    return "Hello World"


app = Litestar(route_handlers=[exc], debugger_module=pdb, debug=True)


if __name__ == "__main__":
    uvicorn.run(
        "qq:app",
        reload=True,
    )

20250126_1011_2117x1270_1737882686

docs/usage/debugging.rst Outdated Show resolved Hide resolved
@euri10
Copy link
Contributor

euri10 commented Jan 26, 2025

ok answering to myself why I couldnt pop in pdb, it is because requires pdb_on_exception=True so I think the docs should show a "working" example.

@oek1ng
Copy link
Contributor Author

oek1ng commented Jan 26, 2025

ok answering to myself why I couldnt pop in pdb, it is because requires pdb_on_exception=True so I think the docs should show a "working" example.

Yeah, you're right, ty

Copy link
Contributor

@euri10 euri10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks !

Copy link

github-actions bot commented Feb 7, 2025

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3967

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dependencies This PR involves changes to the dependencies area/docs This PR involves changes to the documentation area/private-api This PR involves changes to the privatized API area/types This PR involves changes to the custom types pr/external size: medium Triage Required 🏥 This requires triage type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants