Title: Support for Range Types? · Issue #554 · python/typing · GitHub
Open Graph Title: Support for Range Types? · Issue #554 · python/typing
X Title: Support for Range Types? · Issue #554 · python/typing
Description: Is it possible to define a range of integers as a type? Sometimes we might want to constrain an input to a certain range of values. For example, a US ZIP code must be a 5 digit value. I didn't know this before to opening the issue, but a...
Open Graph Description: Is it possible to define a range of integers as a type? Sometimes we might want to constrain an input to a certain range of values. For example, a US ZIP code must be a 5 digit value. I didn't know...
X Description: Is it possible to define a range of integers as a type? Sometimes we might want to constrain an input to a certain range of values. For example, a US ZIP code must be a 5 digit value. I didn't ...
Opengraph URL: https://github.com/python/typing/issues/554
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support for Range Types?","articleBody":"Is it possible to define a range of integers as a type? Sometimes we might want to constrain an input to a certain range of values.\r\n\r\nFor example, a US ZIP code must be a 5 digit value. I didn't know this before to opening the issue, but apparently the lowest ZIP code is in Holtsville, New York (00501) and the highest ZIP code is in Ketchikan, Alaska (99950). It would be great if we could define a type like this:\r\n\r\n```python\r\nfrom typing import RangeType, Tuple\r\n\r\nZipCode = RangeType(low=501, high=99950):\r\n\r\ndef get_gps_coordinate(code: ZipCode) -> Tuple[float, float]:\r\n ...\r\n```\r\n\r\nAnother language that has range types is Ada, which lets you define range types like so:\r\n```ada\r\ntype ZipCode is range 00501 .. 99950;\r\n```","author":{"url":"https://github.com/chang","@type":"Person","name":"chang"},"datePublished":"2018-04-23T04:03:03Z","url":"https://github.com/python/typing/issues/554"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:14bf883c-3690-424e-0449-232e4739a07b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A448:356FBF:2B74287:3B151FA:6B004F94 |
| html-safe-nonce | dd49b67b7fd655d5eca38587df57f7f4363641e07a321ac93c4d22cd2d91ab9a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDQ4OjM1NkZCRjoyQjc0Mjg3OjNCMTUxRkE6NkIwMDRGOTQiLCJ2aXNpdG9yX2lkIjoiNjI1Mzg2NzkwODMwOTQ3MTEyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 86a68922f7bca650496ceb6382772171442b9ed10d81998d21b3130b8a79953f |
| hovercard-subject-tag | issue:316654685 |
| 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/554/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7585445d954ae83178a6b13c23857fbbe59b082c7f632776f43b663ffad2ba80/python/typing/issues/554 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7585445d954ae83178a6b13c23857fbbe59b082c7f632776f43b663ffad2ba80/python/typing/issues/554 |
| og:image:alt | Is it possible to define a range of integers as a type? Sometimes we might want to constrain an input to a certain range of values. For example, a US ZIP code must be a 5 digit value. I didn't know... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chang |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width