GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix all typing issues by Kludex · Pull Request #134 · MagicStack/httptools

Conversation

@Kludex

@Kludex Kludex commented Oct 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@fantix can you please check this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex added 3 commits October 19, 2025 18:08
@Kludex
Fix all typing issues
6805798
@Kludex
push
623b8fe
@Kludex
less permissive
8f1af04
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/parser.pyi
Comment on lines -11 to -19
- on_message_begin()
- on_url(url: bytes)
- on_header(name: bytes, value: bytes)
- on_headers_complete()
- on_body(body: bytes)
- on_message_complete()
- on_chunk_header()
- on_chunk_complete()
- on_status(status: bytes)

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is not needed. Implementers can follow the protocol.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/parser.pyi
- on_chunk_header()
- on_chunk_complete()
- on_status(status: bytes)
def __init__(self, protocol: HTTPProtocol | object) -> None:

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

object is less permissive than Any.


Python still doesn't support "not required class method protocol": https://discuss.python.org/t/discussion-optional-class-and-protocol-fields-and-methods

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/parser.pyi
protocol (HTTPProtocol): Callback interface for the parser.
"""

def set_dangerous_leniencies(

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This was missing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/parser.pyi Outdated
...

def feed_data(self, data: Union[bytes, bytearray, memoryview, array]) -> None:
def feed_data(self, data: Union[bytes, bytearray, memoryview, array[int]]) -> None:

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

array is a Generic.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/protocol.py
Comment on lines +7 to +15
def on_message_begin(self) -> None: ...
def on_url(self, url: bytes) -> None: ...
def on_header(self, name: bytes, value: bytes) -> None: ...
def on_headers_complete(self) -> None: ...
def on_body(self, body: bytes) -> None: ...
def on_message_complete(self) -> None: ...
def on_chunk_header(self) -> None: ...
def on_chunk_complete(self) -> None: ...
def on_status(self, status: bytes) -> None: ...

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Missing self.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/url_parser.pyi
Comment on lines -16 to -25
Returns an instance of ``httptools.URL`` class with the
following attributes:

- schema: bytes
- host: bytes
- port: int
- path: bytes
- query: bytes
- fragment: bytes
- userinfo: bytes

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Irrelevant. The URL is defined above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex
Kludex commented Oct 19, 2025
View reviewed changes
Comment thread httptools/parser/__init__.py
Comment on lines +13 to +29
__all__ = (
# protocol
"HTTPProtocol",
# parser
"HttpParser",
"HttpRequestParser",
"HttpResponseParser",
# errors
"HttpParserError",
"HttpParserCallbackError",
"HttpParserInvalidStatusError",
"HttpParserInvalidMethodError",
"HttpParserInvalidURLError",
"HttpParserUpgrade",
# url_parser
"parse_url",
)

@Kludex Kludex Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Proper definition.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Kludex added 2 commits October 19, 2025 18:48
@Kludex
Add py.typed
dc27351
@Kludex
drop unneeded Union
caa1b51
@Kludex

Kludex commented Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

I've dropped the Unions since they are not needed in pyi files.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kludex
move py.typed up
ab89539
@Kludex

Kludex commented Oct 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I've tested this on uvicorn, it works like a charm. It would be nice to add a type checker in this repository.

EDIT: I meant the typing... 😅

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fantix

fantix commented Oct 19, 2025

Copy link
Copy Markdown
Member

Thank you! Looks there's an error: ImportError: cannot import name 'HttpParser' from 'httptools.parser.parser'

Let me add a CI workflow to check typing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kludex

Kludex commented Oct 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thank you! Looks there's an error: ImportError: cannot import name 'HttpParser' from 'httptools.parser.parser'

Let me add a CI workflow to check typing.

Then it seems the issue is that the parser.pyi exists? Should be __init__.pyi? 🤔

I'm on a plane. I'll fix this tomorrow.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kludex
Push CI
c5e1550
@Kludex

Kludex commented Oct 20, 2025

Copy link
Copy Markdown
Contributor Author

Thank you! Looks there's an error: ImportError: cannot import name 'HttpParser' from 'httptools.parser.parser'

Let me add a CI workflow to check typing.

It seems HttpParser is marked as internal. I've fixed it.

I've added the type checker to the pipeline, but feel free to tweak whatever you want.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kludex

Kludex commented Oct 20, 2025

Copy link
Copy Markdown
Contributor Author

Btw, this gives less frustration to people when contributing to other projects:

Screenshot 2025-10-20 at 10 27 44

You can find it on:

Screenshot 2025-10-20 at 10 28 20
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fantix added 2 commits May 25, 2026 12:15
@fantix
Merge remote-tracking branch 'origin/master' into fix-typing
c25f9b6
@fantix
Bump setup-python and use 3.9 for typechecking
51e7159
fantix
fantix approved these changes May 25, 2026
View reviewed changes
@fantix
fantix merged commit a9bda0e into MagicStack:master May 25, 2026
19 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@fantix fantix mentioned this pull request May 25, 2026
httptools 0.8.0 #147
Merged
pull Bot pushed a commit to sysfce2/python-httptools that referenced this pull request May 25, 2026
@fantix
httptools 0.8.0
cf10ce6
Changes
=======

* Add http-parser and llhttp licenses into the wheels (MagicStack#135)
  (by @justeph in c398a15)

* Mark cython module as free-threading compatible (MagicStack#139)
  (by @kumaraditya303 in 28d1db1)

* Fix all typing issues (MagicStack#134)
  (by @Kludex in a9bda0e)

* Bump llhttp to 9.4.1 (MagicStack#145)
  (by @fantix in e3e8d71)

* Security: fix URL truncation issue (MagicStack#144)
  (by @fantix in a0283f0 for MagicStack#142)

* Allow building with latest setuptools (MagicStack#138)
  (by @OldManYellsAtCloud in c403ad1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fantix fantix fantix approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Kludex @fantix
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.