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 — http: improve types by JelleZijlstra · Pull Request #9055 · python/typeshed

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Nov 1, 2022

Copy link
Copy Markdown
Member

No description provided.

Sorry, something went wrong.

Uh oh!

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

All reactions
JelleZijlstra and others added 2 commits October 31, 2022 21:39
@JelleZijlstra
http: improve types
7bd6409
@pre-commit-ci
[pre-commit.ci] auto fixes from pre-commit.com hooks
ca92fd2
@JelleZijlstra JelleZijlstra mentioned this pull request Nov 1, 2022
Track review of bytes types #9006
Open
@github-actions

This comment has been minimized.

Sign in to view
srittau
srittau requested changes Nov 1, 2022
View reviewed changes
Comment thread stdlib/http/client.pyi
]

_DataType: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str
_DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | ReadableBuffer

@srittau srittau Nov 1, 2022

Copy link
Copy Markdown
Collaborator

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.

HTTPConnection.send() also allows str:

    def request(self, method, url, body=None, headers={}, *,
                encode_chunked=False):
        """Send a complete request to the server."""
        self._send_request(method, url, body, headers, encode_chunked)

    def _send_request(self, method, url, body, headers, encode_chunked):
        # ...
        # It also gets passed to _get_content_length(), which also supports str
        # ...

        if isinstance(body, str):
            # RFC 2616 Section 3.7.1 says that text default has a
            # default charset of iso-8859-1.
            body = _encode(body, 'body')
        self.endheaders(body, encode_chunked=encode_chunked)

I think the best solution is just to add str to the body argument of request manually.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread stdlib/http/server.pyi Outdated
Comment on lines +57 to +59
server: socketserver.BaseServer,
directory: str | None = ...,
index_pages: Sequence[str] | None = ...,

@srittau srittau Nov 1, 2022

Copy link
Copy Markdown
Collaborator

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.

As directory is keyword only and I can't find index_pages anywhere (on 3.9):

Suggested change
server: socketserver.BaseServer,
directory: str | None = ...,
index_pages: Sequence[str] | None = ...,
server: socketserver.BaseServer,
*,
directory: str | None = ...,

(directory is also passed to os.fspath() in later version (but not 3.7), but that's out of scope for this PR, since it needs overloads.)

Sorry, something went wrong.

Uh oh!

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

All reactions

@AlexWaygood AlexWaygood Nov 1, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

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.

index_pages is new in 3.12: python/cpython#31985. So we should branch on if sys.version_info >= (3, 12).

Sorry, something went wrong.

Uh oh!

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

All reactions
@JelleZijlstra
Address feedback
2e733fa
@JelleZijlstra
JelleZijlstra requested a review from srittau November 3, 2022 03:39
@pre-commit-ci
[pre-commit.ci] auto fixes from pre-commit.com hooks
a3b8882
@github-actions

This comment has been minimized.

Sign in to view
@JelleZijlstra
fix stubtest
65171d1
@github-actions

github-actions Bot commented Nov 3, 2022

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

All reactions

Sorry, something went wrong.

Uh oh!

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

srittau
srittau approved these changes Nov 3, 2022
View reviewed changes
@srittau
srittau merged commit 6b70245 into python:main Nov 3, 2022
AlexWaygood added a commit that referenced this pull request Nov 3, 2022
@AlexWaygood
http.server.SimpleHTTPRequestHandler: Fix version branching
05267dd
The stub currently implies that the index_pages parameter has been removed in 3.12. Actually, it was only added in 3.12 :)

See python/cpython#31985. (This is a follow-up to #9055 — cc. @JelleZijlstra.)
@AlexWaygood AlexWaygood mentioned this pull request Nov 3, 2022
http.server.SimpleHTTPRequestHandler: Fix version branching #9075
Merged
@JelleZijlstra
JelleZijlstra deleted the http branch November 3, 2022 14:21
@iamahuman iamahuman mentioned this pull request Sep 22, 2026
Incorrect type declaration for http.server.BaseHTTPRequestHandler.__init__ #7160
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexWaygood AlexWaygood AlexWaygood left review comments
@srittau srittau srittau 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.

3 participants

@JelleZijlstra @srittau @AlexWaygood
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.