René's URL Explorer Experiment


Title: Prevent an implementation for `int` class from operating on `bool` values · Issue #310 · dry-python/classes · GitHub

Open Graph Title: Prevent an implementation for `int` class from operating on `bool` values · Issue #310 · dry-python/classes

X Title: Prevent an implementation for `int` class from operating on `bool` values · Issue #310 · dry-python/classes

Description: Context. Consider the following piece of code. from classes import typeclass @typeclass def render(data_value) -> str: """Pretty-print a value.""" @render.instance(int) def _render_int(data_value: int) -> str: return f'🔢 {data_value}' re...

Open Graph Description: Context. Consider the following piece of code. from classes import typeclass @typeclass def render(data_value) -> str: """Pretty-print a value.""" @render.instance(int) def _render_int(data_value: ...

X Description: Context. Consider the following piece of code. from classes import typeclass @typeclass def render(data_value) -> str: """Pretty-print a value.""" @render.instance(...

Opengraph URL: https://github.com/dry-python/classes/issues/310

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Prevent an implementation for `int` class from operating on `bool` values","articleBody":"**Context.** Consider the following piece of code.\r\n\r\n```python\r\nfrom classes import typeclass\r\n\r\n@typeclass\r\ndef render(data_value) -\u003e str:\r\n    \"\"\"Pretty-print a value.\"\"\"\r\n\r\n@render.instance(int)\r\ndef _render_int(data_value: int) -\u003e str:\r\n    return f'🔢 {data_value}'\r\n\r\nrender(True) == '🔢 True'\r\n```\r\n*(this should be runnable as-is on `classes 0.4.0`.)*\r\n\r\nI would have expected this code to fail with a `NotImplementedError` because the `bool` case wasn't specified; but instead, that case is handled by the `int` implementation because\r\n\r\n```pycon\r\nIn [3]: issubclass(bool, int)\r\nOut[3]: True\r\n```\r\n\r\n**Decision.** In an `int` implementation, recognize if the provided value is actually a `bool` and refuse to process that value.\r\n\r\n**Consequences.** I have been writing in Python for quite a few years now and I might even have encountered this relationship between `int` and `bool` types before, but that is not quite a type of thing that I keep in my short-term memory to be able to instantly recognize.\r\n\r\nI believe this change can help avert bugs which might be hard to trace otherwise.","author":{"url":"https://github.com/anatoly-scherbakov","@type":"Person","name":"anatoly-scherbakov"},"datePublished":"2021-09-13T13:27:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/310/classes/issues/310"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:059ee399-d1b8-c37b-2405-5f5e9a80369e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE342:1E165C:8B6B67:BB9060:69697A4A
html-safe-nonceded075aa4d39c33517088aea67ddc9b96518e3d4ae3478c423db8e2e0d862239
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzQyOjFFMTY1Qzo4QjZCNjc6QkI5MDYwOjY5Njk3QTRBIiwidmlzaXRvcl9pZCI6IjY0MjI3OTIxNTAzMTAyODc5NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2f7b2c3b081fd1c3686dbf8c11323b3363c45131c33f8439335a33872ed829c2
hovercard-subject-tagissue:994893424
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/dry-python/classes/310/issue_layout
twitter:imagehttps://opengraph.githubassets.com/96787c0e82ef1d504cf2d25ddc3708eb01d130ddd7b9fd696a6a0a811829a7ad/dry-python/classes/issues/310
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/96787c0e82ef1d504cf2d25ddc3708eb01d130ddd7b9fd696a6a0a811829a7ad/dry-python/classes/issues/310
og:image:altContext. Consider the following piece of code. from classes import typeclass @typeclass def render(data_value) -> str: """Pretty-print a value.""" @render.instance(int) def _render_int(data_value: ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameanatoly-scherbakov
hostnamegithub.com
expected-hostnamegithub.com
Nonec6f193beb8ff08443adc07685d75302ab8aaf0a135f6e251c3ff3112c8deb881
turbo-cache-controlno-preview
go-importgithub.com/dry-python/classes git https://github.com/dry-python/classes.git
octolytics-dimension-user_id37993755
octolytics-dimension-user_logindry-python
octolytics-dimension-repository_id217621930
octolytics-dimension-repository_nwodry-python/classes
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id217621930
octolytics-dimension-repository_network_root_nwodry-python/classes
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
release212e3e3d3298bf5b313830edfd2399e869f7ea76
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/dry-python/classes/issues/310#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdry-python%2Fclasses%2Fissues%2F310
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdry-python%2Fclasses%2Fissues%2F310
Sign up https://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=dry-python%2Fclasses
Reloadhttps://github.com/dry-python/classes/issues/310
Reloadhttps://github.com/dry-python/classes/issues/310
Reloadhttps://github.com/dry-python/classes/issues/310
dry-python https://github.com/dry-python
classeshttps://github.com/dry-python/classes
Please reload this pagehttps://github.com/dry-python/classes/issues/310
Notifications https://github.com/login?return_to=%2Fdry-python%2Fclasses
Fork 30 https://github.com/login?return_to=%2Fdry-python%2Fclasses
Star 723 https://github.com/login?return_to=%2Fdry-python%2Fclasses
Code https://github.com/dry-python/classes
Issues 21 https://github.com/dry-python/classes/issues
Pull requests 16 https://github.com/dry-python/classes/pulls
Actions https://github.com/dry-python/classes/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/dry-python/classes/security
Please reload this pagehttps://github.com/dry-python/classes/issues/310
Insights https://github.com/dry-python/classes/pulse
Code https://github.com/dry-python/classes
Issues https://github.com/dry-python/classes/issues
Pull requests https://github.com/dry-python/classes/pulls
Actions https://github.com/dry-python/classes/actions
Security https://github.com/dry-python/classes/security
Insights https://github.com/dry-python/classes/pulse
New issuehttps://github.com/login?return_to=https://github.com/dry-python/classes/issues/310
New issuehttps://github.com/login?return_to=https://github.com/dry-python/classes/issues/310
Prevent an implementation for int class from operating on bool valueshttps://github.com/dry-python/classes/issues/310#top
https://github.com/anatoly-scherbakov
https://github.com/anatoly-scherbakov
anatoly-scherbakovhttps://github.com/anatoly-scherbakov
on Sep 13, 2021https://github.com/dry-python/classes/issues/310#issue-994893424
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.