Title: [spec] clarification or change of "`partial\n` in a `py.typed` file" · Issue #2113 · python/typing · GitHub
Open Graph Title: [spec] clarification or change of "`partial\n` in a `py.typed` file" · Issue #2113 · python/typing
X Title: [spec] clarification or change of "`partial\n` in a `py.typed` file" · Issue #2113 · python/typing
Description: Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of partial\n are ambiguous because it could be interpreted as requiring lite...
Open Graph Description: Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of partial\n are ambiguous because i...
X Description: Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of partial\n are ambiguous because i...
Opengraph URL: https://github.com/python/typing/issues/2113
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[spec] clarification or change of \"`partial\\n` in a `py.typed` file\"","articleBody":"Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of `partial\\n` are ambiguous because it could be interpreted as requiring literally a backslash and an n. Furthermore, assuming \\n is actually not to be taken literally (which is reasonable given that other places in the spec use glob stars anyway, although never in something you actually type into a file) it's ambiguous what happens if you use CRLF or CR as line terminators in your file. This also seems to rule out a file that just contains `partial` and then ends, without a newline character (you're not \"supposed to\" do this, but it happens).\n\nTo keep exactly the current behavior, I think this verbiage should be tweaked to \"`partial`, followed by a newline\". Perhaps the linefeed and carriage return characters could be mentioned explicitly, or a mention can be made of universal newlines.\n\nHowever, I am not sure if the current behavior is actually important to specify, and I think other possibilities make more sense. Other possibilities include \"`partial` on a line by itself\", \"`partial` surrounded by any amount of whitespace\", and just \"`partial`\". \"As the sole content of the file\" may be added if desired.\n\nA brief survey suggests that:\n* mypy [does](https://github.com/python/mypy/blob/45aa599633e16b714205445ec67b4bcf80739359/mypy/modulefinder.py#L478) `fscache.read(stub_typed_file).decode().strip() == \"partial\"`, which is not quite the same as the specified check\n* pyright [does](https://github.com/microsoft/pyright/blob/6f3b72c148dc9db557e133b84e0f9a962e31a9b1/packages/pyright-internal/src/analyzer/pyTypedUtils.ts#L56) `(pyTypedContents.match(/partial\\n/) || pyTypedContents.match(/partial\\r\\n/))`, which is certainly a reasonable interpretation of the current spec, especially if you assume that no one ever uses only-CR newlines\n* ty [does](https://github.com/astral-sh/ruff/blob/main/crates/ty_python_semantic/src/module_resolver/path.rs#L182) `to_ascii_lowercase().contains(\"partial\")` to be deliberately permissive, as explained in a comment\n\nThere is a reasonably long discussion about this topic over at https://discuss.python.org/t/pep-561-clarification-regarding-n/32875, but I didn't find it very enlightening.","author":{"url":"https://github.com/wyattscarpenter","@type":"Person","name":"wyattscarpenter"},"datePublished":"2025-11-06T08:21:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2113/typing/issues/2113"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d06a1b49-a758-65a0-0cdb-5dc395f109db |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF30:335C13:8B6A85:BDD760:6969DF77 |
| html-safe-nonce | 4f3f090e69415650ea33d17a4b9606219cf6f41c94be7af1f765252e185c8132 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjMwOjMzNUMxMzo4QjZBODU6QkRENzYwOjY5NjlERjc3IiwidmlzaXRvcl9pZCI6IjQyNDc5MjAyOTQ3Mjc2Mzg5MDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 79213e3356577a2305c4d2c4abcc5ea784960c410116ce5cfc527e90d9b86a7b |
| hovercard-subject-tag | issue:3594663143 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typing/2113/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c2d20c93102d95f2aea0761facfe0f05bce9e8716aef13cdff732a8d7ae1317d/python/typing/issues/2113 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c2d20c93102d95f2aea0761facfe0f05bce9e8716aef13cdff732a8d7ae1317d/python/typing/issues/2113 |
| og:image:alt | Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of partial\n are ambiguous because i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wyattscarpenter |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typing git https://github.com/python/typing.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 24604008 |
| octolytics-dimension-repository_nwo | python/typing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24604008 |
| octolytics-dimension-repository_network_root_nwo | python/typing |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width