René's URL Explorer Experiment


Title: Properties `.start`, `.stop`, `. step` of (generic) `slice[...]` should be optional (`| None`) · Issue #15526 · python/typeshed · GitHub

Open Graph Title: Properties `.start`, `.stop`, `. step` of (generic) `slice[...]` should be optional (`| None`) · Issue #15526 · python/typeshed

X Title: Properties `.start`, `.stop`, `. step` of (generic) `slice[...]` should be optional (`| None`) · Issue #15526 · python/typeshed

Description: Situation #13008 made slice.__new__ more precise. Generic slice[T] accepts T | None as arguments when creating a slice. However, properties .start, .stop, . step of (generic) slice[...] are typed as there respective types, i.e. T in abov...

Open Graph Description: Situation #13008 made slice.__new__ more precise. Generic slice[T] accepts T | None as arguments when creating a slice. However, properties .start, .stop, . step of (generic) slice[...] are typed a...

X Description: Situation #13008 made slice.__new__ more precise. Generic slice[T] accepts T | None as arguments when creating a slice. However, properties .start, .stop, . step of (generic) slice[...] are typed a...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Properties `.start`, `.stop`, `. step` of (generic) `slice[...]` should be optional (`| None`)","articleBody":"# Situation\n[#13008](https://github.com/python/typeshed/pull/13008) made `slice.__new__` more precise. Generic `slice[T]` accepts `T | None` as arguments when creating a `slice`.\nHowever, properties `.start`, `.stop`, `. step` of (generic) `slice[...]` are typed as there respective types, i.e. `T` in above example.\n# Consequence\nThis leads to typecheckers accepting:\n```\ndef test(s: slice[int]) -> None:\n    assert_type(s.start, int)\n    if s.start is None:\n        assert_never(s.start)\n```\nwhereas below obviously breaks:\n```\ntest(slice(42))\n```\n# Solution\nTherefore, I suggest properties `.start`, `.stop`, `. step` should have optional (`| None`) return types:\n```\n    @property\n    def start(self) -> _StartT_co | None: ...\n    @property\n    def step(self) -> _StepT_co | None: ...\n    @property\n    def stop(self) -> _StopT_co | None: ...\n```\n# Alternative\nCurrently, `typeshed` uses `slice[...]` as `slice[T | None]` explicitly as per [#13007](https://github.com/python/typeshed/pull/13007), e.g.\n```\nclass str:\n    def __getitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> str: ...\n```\nWhile that works/typechecks correctly:\n```\ndef test(s: slice[int | None]) -> None:\n    assert_type(s.start, int | None)\n    if s.start is None or isinstance(s.start, int):\n        pass\n    else:\n        assert_never(s.start)\n\ntest(slice(42))   # okay\ntest(slice('x'))  # error: Argument 1 to \"slice\" has incompatible type \"str\"; expected \"int | None\"  [arg-type]\n```\nI see as downsides:\n1. it's error-prone / less ergonomic\n2. it renders part of [#13008](https://github.com/python/typeshed/pull/13008) `__new__` overloading complexity superfluous\n3. it made [#13007](https://github.com/python/typeshed/pull/13007) more complex\n# Question\n@Sachaa-Thanasius: Was the proposed solution considered for [#13007](https://github.com/python/typeshed/pull/13007)?","author":{"url":"https://github.com/Dutcho","@type":"Person","name":"Dutcho"},"datePublished":"2026-03-19T11:27:45Z","url":"https://github.com/python/typeshed/issues/15526"}

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:b1042b34-cc2a-45f8-f280-c9eb2b108fec
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCB6E:37BEAD:219C9FF:2DCD5B1:6B002601
html-safe-noncef5ff5b82f810ed0d93ee36aa071865027c29abe7ff3285a43994a70e22f9a36f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjZFOjM3QkVBRDoyMTlDOUZGOjJEQ0Q1QjE6NkIwMDI2MDEiLCJ2aXNpdG9yX2lkIjoiNjY0MjQ3MzM3MDk3NTc0MTQ0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2899231ff280696a97e9939c36a2bf48890331218ef86a740780d9c782888f68
hovercard-subject-tagissue:4101053056
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/15526/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5b36263e168a1e5502926e16098cb8c9560b071d808f9fd3f6146312b12f7aef/python/typeshed/issues/15526
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5b36263e168a1e5502926e16098cb8c9560b071d808f9fd3f6146312b12f7aef/python/typeshed/issues/15526
og:image:altSituation #13008 made slice.__new__ more precise. Generic slice[T] accepts T | None as arguments when creating a slice. However, properties .start, .stop, . step of (generic) slice[...] are typed a...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameDutcho
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
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
release44c658b24abf00491fb7ae5f56d42c9f38cbeab2
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/15526#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F15526
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%2F15526
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/15526
Reloadhttps://github.com/python/typeshed/issues/15526
Reloadhttps://github.com/python/typeshed/issues/15526
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/15526
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/15526
Properties .start, .stop, . step of (generic) slice[...] should be optional (| None)https://github.com/python/typeshed/issues/15526#top
https://github.com/Dutcho
Dutchohttps://github.com/Dutcho
on Mar 19, 2026https://github.com/python/typeshed/issues/15526#issue-4101053056
#13008https://github.com/python/typeshed/pull/13008
#13007https://github.com/python/typeshed/pull/13007
#13008https://github.com/python/typeshed/pull/13008
#13007https://github.com/python/typeshed/pull/13007
@Sachaa-Thanasiushttps://github.com/Sachaa-Thanasius
#13007https://github.com/python/typeshed/pull/13007
https://github.com/srittau
srittauhttps://github.com/srittau
on Mar 19, 2026https://github.com/python/typeshed/issues/15526#issuecomment-4092100314
https://github.com/srittau
srittauhttps://github.com/srittau
on Mar 19, 2026https://github.com/python/typeshed/issues/15526#issuecomment-4092101876
@randolf-scholzhttps://github.com/randolf-scholz
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Mar 19, 2026https://github.com/python/typeshed/issues/15526#issuecomment-4092236874
#12899 (comment)https://github.com/python/typeshed/pull/12899#issuecomment-2435961197
3010edahttps://github.com/python/typeshed/commit/3010eda2245bc8f8ce21660035fb533423e7a475
#12899 (comment)https://github.com/python/typeshed/pull/12899#issuecomment-2435910825
https://github.com/pydata/xarray/blob/a1c0617051260cc84789bfc6c31a7fef3d64f01b/xarray/core/indexing.py#L318https://github.com/pydata/xarray/blob/a1c0617051260cc84789bfc6c31a7fef3d64f01b/xarray/core/indexing.py#L318
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Mar 19, 2026https://github.com/python/typeshed/issues/15526#issuecomment-4092264291
#12899 (comment)https://github.com/python/typeshed/pull/12899#issuecomment-2437479047
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Mar 22, 2026https://github.com/python/typeshed/issues/15526#issuecomment-4105912736
#15536https://github.com/python/typeshed/pull/15536
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Mar 22, 2026https://github.com/python/typeshed/issues/15526#issuecomment-4105919510
https://mypy-play.net/?mypy=master&python=3.12&gist=d1caa6c5608d51630693a733005f359ahttps://mypy-play.net/?mypy=master&python=3.12&gist=d1caa6c5608d51630693a733005f359a
https://mypy-play.net/?mypy=1.19.1&python=3.12&gist=c4c5a515235ed73a1d32f787bc3ec560https://mypy-play.net/?mypy=1.19.1&python=3.12&gist=c4c5a515235ed73a1d32f787bc3ec560
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/15526
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/15526
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.