Skip to content

Add some more typing for the public api#1619

Merged
rchiodo merged 2 commits intomicrosoft:mainfrom
rchiodo:rchiodo/add_types
Jul 3, 2024
Merged

Add some more typing for the public api#1619
rchiodo merged 2 commits intomicrosoft:mainfrom
rchiodo:rchiodo/add_types

Conversation

@rchiodo
Copy link
Copy Markdown
Contributor

@rchiodo rchiodo commented Jul 3, 2024

Was just using Pylance to test debugpy and started added some typing to the public API

@rchiodo rchiodo requested a review from a team as a code owner July 3, 2024 18:25
Comment thread src/debugpy/server/cli.py Outdated
class Options(object):
mode = None
address = None
address: "Optional[tuple[str, int]]" = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the general feeling in the typing community is that Foo | None is more readable than Optional[Foo].

https://typing.readthedocs.io/en/latest/source/modernizing.html#typing-union-and-typing-optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll change them to that then.

Comment thread src/debugpy/server/cli.py
class Options(object):
mode = None
address = None
address: "tuple[str, int] | None" = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the quotes are unnecessary?

Suggested change
address: "tuple[str, int] | None" = None
address: tuple[str, int] | None = None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They're only unnecessary on newer Python versions. Debugpy has to run on 3.8 I believe.

image

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Oh, interesting, I haven't run into that before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah debugpy's pyproject forces 3.8:

[tool.pyright]
pythonVersion = "3.8"

@rchiodo rchiodo merged commit 1d7c662 into microsoft:main Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants