René's URL Explorer Experiment


Title: Outdated/Incorrect annotations for `os.startfile` · Issue #10991 · python/typeshed · GitHub

Open Graph Title: Outdated/Incorrect annotations for `os.startfile` · Issue #10991 · python/typeshed

X Title: Outdated/Incorrect annotations for `os.startfile` · Issue #10991 · python/typeshed

Description: In my opinion, the annotations for os.startfile have major problems that have been overlooked for the past few years. For reference, the current annotations in stdlib/os__init__.pyi if sys.platform == "win32": if sys.version_info >= (3, ...

Open Graph Description: In my opinion, the annotations for os.startfile have major problems that have been overlooked for the past few years. For reference, the current annotations in stdlib/os__init__.pyi if sys.platform...

X Description: In my opinion, the annotations for os.startfile have major problems that have been overlooked for the past few years. For reference, the current annotations in stdlib/os__init__.pyi if sys.platform...

Opengraph URL: https://github.com/python/typeshed/issues/10991

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Outdated/Incorrect annotations for `os.startfile`","articleBody":"In my opinion, the annotations for `os.startfile` have major problems that have been overlooked for the past few years.\r\n\r\nFor reference, the current annotations in [stdlib/os__init__.pyi](https://github.com/python/typeshed/blob/main/stdlib/os/__init__.pyi#L927C10-L927C10)\r\n```python\r\nif sys.platform == \"win32\":\r\n    if sys.version_info >= (3, 8):\r\n        def startfile(path: StrOrBytesPath, operation: str | None = None) -> None: ...\r\n    else:\r\n        def startfile(filepath: StrOrBytesPath, operation: str | None = None) -> None: ...\r\n```\r\n\r\n## 1. Renaming the first argument for `filepath` to `path` in >= 3.8\r\n\r\nIs there reason why this change has been added? While the official docs list the argument name as `path` ([docs](https://docs.python.org/3/library/os.html#os.startfile)), the CPython source code has the first argument as `filepath` ([CPython/main](https://github.com/python/cpython/blob/f55cb44359821e71c29903f2152b4658509dac0d/Modules/clinic/posixmodule.c.h#L9784)), and firing up a REPL to check actual behavior mirrors the same:\r\n\r\n```\r\n>>> from os import startfile\r\n>>> startfile(path='explorer')\r\nTraceback (most recent call last):\r\n  File \"\u003cpyshell#1>\", line 1, in \u003cmodule>\r\n    startfile(path='explorer')\r\nTypeError: startfile() missing required argument 'filepath' (pos 1)\r\n```\r\n\r\nTo me, it looks like a case of incorrect documentation that has been transferred into type annotations without checking whether it mirrors runtime behaviour.\r\n\r\n## 2. Allowing `None` for `operation` argument\r\n\r\nThis is another annotation that conflicts with runtime behaviour:\r\n\r\n```\r\n>>> from os import startfile\r\n>>> startfile(filepath='explorer', operation=None)\r\nTraceback (most recent call last):\r\n  File \"\u003cpyshell#3>\", line 1, in \u003cmodule>\r\n    startfile(filepath='explorer', operation=None)\r\nTypeError: startfile() argument 2 must be str, not None\r\n```\r\n\r\nI'll be honest, I'm not 100% sure what the correct default value is. Maybe just the empty string `\"\"` since the logic itself sits in Windows' own ShellExecuteW?\r\n\r\n## 3. Missing arguments from >= 3.10\r\n\r\n`os.startfile` gained additional arguments in Python 3.10, but they are all missing from the type annotations.\r\n\r\n```python\r\ndef startfile(\r\n    filepath: StrOrBytesPath, \r\n    operation: str = \"\",  # Can't be None during runtime\r\n    arguments: str = \"\",  # Can't be None during runtime\r\n    cwd: StrOrBytesPath | None = None,  # Can be None during runtime\r\n    show_cmd: int = 1  # Can't be None during runtime, 1 from CPython source\r\n) -> None: ...\r\n```\r\n\r\n## Disclaimer\r\n\r\nI've been investigating this issue from my limited view point. There could be historic reasons why some things are the way they are. That's why I'm opening this as an Issue open for discussion instead of a PR. If you or somebody you know have more insight on this topic, please do share.\r\n\r\n## My proposal\r\n\r\nIf there are no mistakes in my assumptions, I would suggest the following annotations for `os.startfile`:\r\n\r\n```python\r\nif sys.platform == \"win32\":\r\n    if sys.version_info >= (3, 10):\r\n        def startfile(filepath: StrOrBytesPath, operation: str = \"\", arguments: str = \"\", cwd: StrOrBytesPath | None = None, show_cmd: int = 1) -> None: ...\r\n    else:\r\n        def startfile(filepath: StrOrBytesPath, operation: str = '') -> None: ...\r\n```","author":{"url":"https://github.com/Jakob-Stadler","@type":"Person","name":"Jakob-Stadler"},"datePublished":"2023-11-07T16:56:47Z","url":"https://github.com/python/typeshed/issues/10991"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7ac4a1fe-9efc-19ab-29e4-23d2d534dcf0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD122:CF959:2A5E875:377BE24:6B0007DC
html-safe-nonce890fa5a8cff51ac586caacd6938b9b51fa9f925cfb64a7325091159870947a20
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTIyOkNGOTU5OjJBNUU4NzU6Mzc3QkUyNDo2QjAwMDdEQyIsInZpc2l0b3JfaWQiOiI5MTUwNzI4MDI2OTU3Mjg1MzQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac05d63b463475e1eab63dbea17a9eb9901b449ab3ca8fa54cf4bc84a30f0e2628
hovercard-subject-tagissue:1981812045
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/10991/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1643358fe1ea6b39d87c77f1c703e23b451d67432d1915699f10a28ee2541291/python/typeshed/issues/10991
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1643358fe1ea6b39d87c77f1c703e23b451d67432d1915699f10a28ee2541291/python/typeshed/issues/10991
og:image:altIn my opinion, the annotations for os.startfile have major problems that have been overlooked for the past few years. For reference, the current annotations in stdlib/os__init__.pyi if sys.platform...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJakob-Stadler
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
turbo-cache-controlno-preview
go-importgithub.com/python/typeshed git https://github.com/python/typeshed.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id31696383
octolytics-dimension-repository_nwopython/typeshed
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31696383
octolytics-dimension-repository_network_root_nwopython/typeshed
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release16a11879678aaf97e2a42c33ee70830aa084fa37
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/10991#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F10991
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F10991
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/10991
Reloadhttps://github.com/python/typeshed/issues/10991
Reloadhttps://github.com/python/typeshed/issues/10991
pythonhttps://github.com/python
typeshedhttps://github.com/python/typeshed
Codehttps://github.com/python/typeshed
Issues196 (196)https://github.com/python/typeshed/issues
Pull requests251 (251)https://github.com/python/typeshed/pulls
Actionshttps://github.com/python/typeshed/actions
Security and qualityhttps://github.com/python/typeshed/security
Insightshttps://github.com/python/typeshed/insights
https://github.com/python/typeshed
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/10991
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/10991
Outdated/Incorrect annotations for os.startfilehttps://github.com/python/typeshed/issues/10991#top
stubs: false negativeType checkers do not report an error, but shouldhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20negative%22
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
https://github.com/Jakob-Stadler
Jakob-Stadlerhttps://github.com/Jakob-Stadler
on Nov 7, 2023https://github.com/python/typeshed/issues/10991#issue-1981812045
stdlib/os__init__.pyihttps://github.com/python/typeshed/blob/main/stdlib/os/__init__.pyi#L927C10-L927C10
docshttps://docs.python.org/3/library/os.html#os.startfile
CPython/mainhttps://github.com/python/cpython/blob/f55cb44359821e71c29903f2152b4658509dac0d/Modules/clinic/posixmodule.c.h#L9784
https://github.com/srittau
srittauhttps://github.com/srittau
on Nov 7, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1799867511
#9815https://github.com/python/typeshed/pull/9815
@AlexWaygoodhttps://github.com/AlexWaygood
srittauhttps://github.com/srittau
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
stubs: false negativeType checkers do not report an error, but shouldhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20negative%22
on Nov 7, 2023https://github.com/python/typeshed/issues/10991#event-10891741478
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Nov 7, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1799918417
#9815https://github.com/python/typeshed/pull/9815
Jakob-Stadlerhttps://github.com/Jakob-Stadler
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#event-10902549488
stdlib: Fix os.startfilehttps://github.com/Jakob-Stadler/typeshed/commit/29ef72e29527fabe5ab8edcb685c166561dff280
29ef72ehttps://github.com/Jakob-Stadler/typeshed/commit/29ef72e29527fabe5ab8edcb685c166561dff280
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802167503
typeshed/tests/stubtest_allowlists/win32.txthttps://github.com/python/typeshed/blob/b36f3c522910ae6c93b9fc894a6526e8b4919807/tests/stubtest_allowlists/win32.txt#L30
b36f3c5https://github.com/python/typeshed/commit/b36f3c522910ae6c93b9fc894a6526e8b4919807
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802173593
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802176200
https://github.com/Jakob-Stadler
Jakob-Stadlerhttps://github.com/Jakob-Stadler
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802176549
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802180103
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802184104
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1802187223
hauntsaninjahttps://github.com/hauntsaninja
completedhttps://github.com/python/typeshed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
d6403b1https://github.com/python/typeshed/commit/d6403b14aa300f40abfe91dc8d092734b56fa570
on Nov 8, 2023https://github.com/python/typeshed/issues/10991#event-10906901159
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Nov 9, 2023https://github.com/python/typeshed/issues/10991#issuecomment-1803762556
python/cpython#87233https://github.com/python/cpython/issues/87233
areslerhttps://github.com/aresler
on Jan 26, 2024https://github.com/python/typeshed/issues/10991#event-11614289516
stdlib: Fix os.startfile (python#10996)https://github.com/aresler/typeshed/commit/d6403b14aa300f40abfe91dc8d092734b56fa570
python#10996https://github.com/python/typeshed/pull/10996
https://docs.github.com/articles/closing-issues-via-commit-messages
d6403b1https://github.com/aresler/typeshed/commit/d6403b14aa300f40abfe91dc8d092734b56fa570
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/10991
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/10991
stubs: false negativeType checkers do not report an error, but shouldhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20negative%22
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.