Skip to content

Add type annotations to library code#459

Merged
csernazs merged 4 commits intocsernazs:masterfrom
HayaoSuzuki:fix/add-type-hint
Jan 30, 2026
Merged

Add type annotations to library code#459
csernazs merged 4 commits intocsernazs:masterfrom
HayaoSuzuki:fix/add-type-hint

Conversation

@HayaoSuzuki
Copy link
Contributor

Add type hints to pass mypy --strict on pytest_httpserver/.

@HayaoSuzuki HayaoSuzuki marked this pull request as ready for review January 29, 2026 02:03
return response

def __enter__(self):
def __enter__(self) -> HTTPServerBase: # noqa: PYI034
Copy link
Owner

Choose a reason for hiding this comment

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

Could this be Self?

Suggested change
def __enter__(self) -> HTTPServerBase: # noqa: PYI034
def __enter__(self) -> Self:

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for the PR! I submitted my comments above.

Copy link
Contributor Author

@HayaoSuzuki HayaoSuzuki Jan 29, 2026

Choose a reason for hiding this comment

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

Done. I initially avoided using Self because it's only available in Python 3.11+, and I didn't want to add extra dependencies. However, I've now added typing_extensions as a dev dependency (for Python < 3.11) to enable Self.

@HayaoSuzuki HayaoSuzuki requested a review from csernazs January 29, 2026 22:40
@csernazs
Copy link
Owner

Thank you very much for this PR, this makes the code significantly better!

@csernazs csernazs merged commit e20f91a into csernazs:master Jan 30, 2026
11 checks passed
@HayaoSuzuki HayaoSuzuki deleted the fix/add-type-hint branch January 30, 2026 10:20
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