René's URL Explorer Experiment


Title: Decide how to deal with str/unicode · Issue #1141 · python/mypy · GitHub

Open Graph Title: Decide how to deal with str/unicode · Issue #1141 · python/mypy

X Title: Decide how to deal with str/unicode · Issue #1141 · python/mypy

Description: We should agree on how we expect the string types to be used in Python 2 code. There are at least four ways we can approach this: Make str usually valid when unicode is expected. This is how mypy currently works, and this is similar to h...

Open Graph Description: We should agree on how we expect the string types to be used in Python 2 code. There are at least four ways we can approach this: Make str usually valid when unicode is expected. This is how mypy c...

X Description: We should agree on how we expect the string types to be used in Python 2 code. There are at least four ways we can approach this: Make str usually valid when unicode is expected. This is how mypy c...

Opengraph URL: https://github.com/python/mypy/issues/1141

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Decide how to deal with str/unicode","articleBody":"We should agree on how we expect the string types to be used in Python 2 code.\n\nThere are at least four ways we can approach this:\n1.    Make `str` usually valid when `unicode` is expected. This is how mypy currently works, and this is similar to how PEP 484 defines `bytearray` / `bytes` compatibility. This will correspond to runtime semantics, but it's not safe as non-ascii characters in `str` objects will result in programs sometimes blowing up. A 7-bit `str` instance is almost always valid at runtime when `unicode` is expected.\n2.    Get rid of the `str -> unicode` promotion and use `Union[str, unicode]` everywhere (or create an alias for it). This is almost like approach 1, except that we have a different name for `unicode` and more complex error messages and a complex programming model due to the proliferation of union types. There is potential for some additional type safety by using just `unicode` in user code.\n3.    Enforce explicit `str` / `unicode` distinction in Python 2 code, similar to Python 3 (`str` would behave more or less like Python 3 `bytes`), and discourage union types. This will make it harder to annotate existing Python 2 programs which often use the two types almost interchangeably, but it will make programs safer.\n4.    Have three different string types: `bytes` (distinct from from `str`) means 8-bit `str` instances -- these aren't compatible with `unicode`. `str` means ascii `str` instances. These are compatible with `bytes` and `unicode`, but not the other way around. `unicode` means `unicode` instances and isn't special. A string literal will have implicit type `str` or `bytes` depending on whether it only has ascii characters. This approach should be pretty safe and potentially also makes it fairly easy to adapt existing code, but harder than with approach 1.\n\nThese also affect how stubs should be written and thus it would be best if every tool using typeshed could use the same approach:\n-    For approach 1, stubs should usually use `str`, `unicode` or `AnyStr`. This is how many stubs are written already.\n-    For approach 2, stubs should use `str`, `Uniont[str, unicode]` or `AnyStr` for attributes and function arguments, and return types could additionally use plain `unicode`. Return types would in general be hard to specify precisely, as it may be difficult to predict whether a function called with `str` or combination of `str` and `unicode` returns `str`, `unicode` or `Union[str, unicode]`. In approach 1 we can safely fall back to `unicode` if unsure. `AnyStr` would be less useful as we could have mixed function arguments like `(str, unicode)` easily (see the typeshed issues mentioned below for more about this).\n-    For approach 3, stubs would usually use either `str`, `unicode` or `AnyStr`, but `unicode` wouldn't accept plain `str` objects.\n-    For approach 4, stubs could use three different types (`bytes`, `str`, `unicode`) in addition to `AnyStr`, and these would all behave differently. Unlike the first three approaches, `AnyStr` would range over `str`, `unicode` and `bytes` in Python 2 mode.\n\nNote that mypy currently assumes approach 1 and I don't know how well the other approaches would work in practice.\n\n[This was adapted from a comment on #1135; see the original issue for more discussion. Also, https://github.com/python/typeshed/issues/50 is relevant.]\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2016-01-21T16:30:51Z","url":"https://github.com/python/mypy/issues/1141"}

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:eb933ecf-3034-30f6-f92b-d30a0fb31d4d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8B18:2FF516:50080B:6C13F0:6B002F64
html-safe-nonce7ea8a676d368c8a3e19ce6ca8c92e74ed3fb11d5842c4b1691cfa5b6614bb12a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjE4OjJGRjUxNjo1MDA4MEI6NkMxM0YwOjZCMDAyRjY0IiwidmlzaXRvcl9pZCI6IjY5NDY1NTk4ODU5MTU5OTE5MDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9f701523ba4fb8fca43164f21756c23bece16cacab5b46dd399bf8b52e5fe5b8
hovercard-subject-tagissue:127963713
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/mypy/1141/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bf008bbcfc587a1a0d6047628d57b21bf7e73180bf6fb6f15daa66ff72e29d4f/python/mypy/issues/1141
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bf008bbcfc587a1a0d6047628d57b21bf7e73180bf6fb6f15daa66ff72e29d4f/python/mypy/issues/1141
og:image:altWe should agree on how we expect the string types to be used in Python 2 code. There are at least four ways we can approach this: Make str usually valid when unicode is expected. This is how mypy c...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJukkaL
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
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
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/1141#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F1141
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%2Fmypy%2Fissues%2F1141
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%2Fmypy
Reloadhttps://github.com/python/mypy/issues/1141
Reloadhttps://github.com/python/mypy/issues/1141
Reloadhttps://github.com/python/mypy/issues/1141
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests547 (547)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/1141
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/1141
Decide how to deal with str/unicodehttps://github.com/python/mypy/issues/1141#top
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
priority-1-normalhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-1-normal%22
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issue-127963713
#1135https://github.com/python/mypy/issues/1135
python/typeshed/issues/50https://github.com/python/typeshed/issues/50
Nexthttps://github.com/python/mypy/issues/1141?timeline_page=1
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173651700
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173658459
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173665777
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173673105
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173685110
https://github.com/gnprice
gnpricehttps://github.com/gnprice
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173689230
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173693120
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jan 21, 2016https://github.com/python/mypy/issues/1141#issuecomment-173693361
https://github.com/matthiaskramm
matthiaskrammhttps://github.com/matthiaskramm
on Jan 22, 2016https://github.com/python/mypy/issues/1141#issuecomment-173791043
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 22, 2016https://github.com/python/mypy/issues/1141#issuecomment-173878612
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 22, 2016https://github.com/python/mypy/issues/1141#issuecomment-173886824
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 22, 2016https://github.com/python/mypy/issues/1141#issuecomment-173930551
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jan 24, 2016https://github.com/python/mypy/issues/1141#issuecomment-174261388
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jan 26, 2016https://github.com/python/mypy/issues/1141#issuecomment-175137689
ddfisherhttps://github.com/ddfisher
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on Mar 1, 2016https://github.com/python/mypy/issues/1141#event-573905494
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Apr 24, 2016https://github.com/python/mypy/issues/1141#issuecomment-213998436
gvanrossumhttps://github.com/gvanrossum
Bytes-Unicodehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22Bytes-Unicode%22
on Aug 5, 2016https://github.com/python/mypy/issues/1141#event-747052272
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 10, 2016https://github.com/python/mypy/issues/1141#issuecomment-238764588
change to typed_asthttps://github.com/dropbox/typed_ast/issues/10
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Aug 10, 2016https://github.com/python/mypy/issues/1141#issuecomment-238927047
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 10, 2016https://github.com/python/mypy/issues/1141#issuecomment-238931602
@JukkaLhttps://github.com/JukkaL
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Aug 11, 2016https://github.com/python/mypy/issues/1141#issuecomment-239194762
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 12, 2016https://github.com/python/mypy/issues/1141#issuecomment-239362625
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Aug 12, 2016https://github.com/python/mypy/issues/1141#issuecomment-239423912
@gvanrossumhttps://github.com/gvanrossum
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 16, 2016https://github.com/python/mypy/issues/1141#issuecomment-240270355
python/typing#208https://github.com/python/typing/issues/208
gvanrossumhttps://github.com/gvanrossum
priority-1-normalhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-1-normal%22
Bytes-Unicodehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22Bytes-Unicode%22
on Jan 6, 2017https://github.com/python/mypy/issues/1141#event-914705448
gvanrossumhttps://github.com/gvanrossum
on Mar 29, 2017https://github.com/python/mypy/issues/1141#event-1021273905
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Aug 9, 2017https://github.com/python/mypy/issues/1141#issuecomment-321196477
python/typing#208https://github.com/python/typing/issues/208
JukkaLhttps://github.com/JukkaL
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 9, 2017https://github.com/python/mypy/issues/1141#event-1198686915
n8henriehttps://github.com/n8henrie
on Jan 9, 2018https://github.com/python/mypy/issues/1141#event-1416644305
Use Union[bytes, Text] instead of AnyStrhttps://github.com/n8henrie/typeshed/commit/da189bddfc62702df07a878b94577f239b82f631
da189bdhttps://github.com/n8henrie/typeshed/commit/da189bddfc62702df07a878b94577f239b82f631
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/1141
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/1141
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
priority-1-normalhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-1-normal%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.