René's URL Explorer Experiment


Title: add option to use dataclasses instead of attrs in generated code by eli-bl · Pull Request #1158 · openapi-generators/openapi-python-client · GitHub

Open Graph Title: add option to use dataclasses instead of attrs in generated code by eli-bl · Pull Request #1158 · openapi-generators/openapi-python-client

X Title: add option to use dataclasses instead of attrs in generated code by eli-bl · Pull Request #1158 · openapi-generators/openapi-python-client

Description: The last time this idea came up (#743), @dbanty felt that there wasn't a compelling reason to switch from attrs. I decided anyway to see how much of a lift it would be— in the generated code, that is, not in the generator. A few reasons: In my main use case, which is creating a library to be used by all sorts of third-party applications, there's an incentive to minimize external dependencies if possible. Even though attrs is very popular, I think it's likely to become somewhat less of a standard as Python's dataclasses module keeps on copying features from it. It's true that attrs has some features that dataclasses doesn't, but we're not really using those features anyway in the generated code (with one exception that I'll mention below). Mostly we're just using the simplest possible attribute declaration pattern in model classes. As I expected, implementing this for the model classes was pretty simple. The only other place we were using attrs in the generated code was in the Client and AuthenticatedClient classes, and there things got trickier. In those classes, we were taking advantage of attrs's alias option in order to define underscored attributes that the app isn't meant to access directly, but that can still be set by name without the underscore in the initializer. You can't do that with dataclasses. However, since the app isn't meant to access them directly, I felt freer to change things there... and attrs/dataclass-type behavior is not really inherent to what the client classes are for, from the app's point of view, it's just an implementation detail. So, in use_dataclasses mode, I changed the clients to plain Python classes with no attrs/dataclass decorators—and moved those Httpx-related attributes into a separate dataclass, so we could still take advantage of copy-and-set behavior for builder methods. That is a fairly different implementation and code structure, which makes the Jinja template a bit hairy, but you can see what it ends up looking like here. However, when you're not in use_dataclasses mode, the implementation does not change at all (you can see there are no changes to existing code in golden_record), so I believe this is not a breaking change. (We could decide to unify those implementations by backporting those changes to the not-using-dataclasses mode, so the only differences between the two would be the decorator names. I do think that'd be a little bit cleaner— the Httpx options do all go together, and I don't think there's a compelling reason to have them be separate attributes on the client class. And, again, apps were never meant to access those directly... but in Python, we couldn't prevent that, so that could be considered a breaking change depending on your standards for what is a public/supported interface.)

Open Graph Description: The last time this idea came up (#743), @dbanty felt that there wasn't a compelling reason to switch from attrs. I decided anyway to see how much of a lift it would be— in the generated code, t...

X Description: The last time this idea came up (#743), @dbanty felt that there wasn't a compelling reason to switch from attrs. I decided anyway to see how much of a lift it would be— in the generated cod...

Opengraph URL: https://github.com/openapi-generators/openapi-python-client/pull/1158

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:638e198d-9b88-c3c3-18f6-e5a860a0df5f
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idDD76:3836D9:5885496:73E1590:69807046
html-safe-nonce3d3ccdafa1705706165b86f10fd0a46225b2ccf9c1502cb8390bebc2aa33490f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDc2OjM4MzZEOTo1ODg1NDk2OjczRTE1OTA6Njk4MDcwNDYiLCJ2aXNpdG9yX2lkIjoiNzk0Mjk2MTg5MDE5NDM4NzAxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4b564ec3cc8ef00ba077b08dfe6cfa89886b95dc9608e5c47897f04d131083bf
hovercard-subject-tagpull_request:2163599900
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/openapi-generators/openapi-python-client/pull/1158/checks
twitter:imagehttps://avatars.githubusercontent.com/u/170372326?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/170372326?s=400&v=4
og:image:altThe last time this idea came up (#743), @dbanty felt that there wasn't a compelling reason to switch from attrs. I decided anyway to see how much of a lift it would be— in the generated code, t...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0959b1a93ca48b0c88b3bddbdfd04ca43f388cb1a8293105a28c5ef6e8079db8
turbo-cache-controlno-preview
go-importgithub.com/openapi-generators/openapi-python-client git https://github.com/openapi-generators/openapi-python-client.git
octolytics-dimension-user_id84925606
octolytics-dimension-user_loginopenapi-generators
octolytics-dimension-repository_id240776275
octolytics-dimension-repository_nwoopenapi-generators/openapi-python-client
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id240776275
octolytics-dimension-repository_network_root_nwoopenapi-generators/openapi-python-client
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release78307334c66591a8f87f493dd2968126b34961dd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenapi-generators%2Fopenapi-python-client%2Fpull%2F1158%2Fchecks
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://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenapi-generators%2Fopenapi-python-client%2Fpull%2F1158%2Fchecks
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=openapi-generators%2Fopenapi-python-client
Reloadhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
Reloadhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
Reloadhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
openapi-generators https://patch-diff.githubusercontent.com/openapi-generators
openapi-python-clienthttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Fork 264 https://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Star 1.9k https://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Code https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client
Issues 77 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/issues
Pull requests 14 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulls
Discussions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/discussions
Actions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions
Security 2 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/security
Insights https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulse
Code https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client
Issues https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/issues
Pull requests https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulls
Discussions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/discussions
Actions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions
Security https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/security
Insights https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fopenapi-generators%2Fopenapi-python-client%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client%2Fissues%2Fnew%2Fchoose
eli-blhttps://patch-diff.githubusercontent.com/eli-bl
openapi-generators:mainhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/tree/main
benchling:dataclasseshttps://patch-diff.githubusercontent.com/benchling/openapi-python-client/tree/dataclasses
Conversation 1 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158
Commits 2 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/commits
Checks 0 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
Files changed https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/files
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
add option to use dataclasses instead of attrs in generated code https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks#top
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1158/checks
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.