René's URL Explorer Experiment


Title: Fix HasCustomStr to recognise custom __repr__ as a meaningful str (fixes #595) by shivamtiwari3 · Pull Request #653 · google/python-fire · GitHub

Open Graph Title: Fix HasCustomStr to recognise custom __repr__ as a meaningful str (fixes #595) by shivamtiwari3 · Pull Request #653 · google/python-fire

X Title: Fix HasCustomStr to recognise custom __repr__ as a meaningful str (fixes #595) by shivamtiwari3 · Pull Request #653 · google/python-fire

Description: Summary Fixes #595. Objects that override __repr__ but not __str__ (e.g. datasets.Dataset from HuggingFace) were shown as a help screen instead of being printed, because HasCustomStr only checked for a custom __str__. Problem Python's object.__str__ delegates to __repr__, so a class that defines a custom __repr__ already produces a meaningful custom string via str(obj) — even without defining __str__. However, HasCustomStr in value_types.py only inspected __str__: str_attr = class_attrs.get('__str__') if str_attr and str_attr.defining_class is not object: return True # __repr__-only classes fall through → False → help screen shown This caused fire.Fire(main) to show the datasets.Dataset help screen rather than the dataset's repr string. Solution After the existing __str__ check, also look for a custom __repr__ — but only on user-defined (non-stdlib) types, so that Python built-in containers (dict, list, OrderedDict, …) continue to be treated as navigable groups rather than values. The guard uses sys.stdlib_module_names (Python ≥ 3.10) and falls back to a minimal sentinel set for older interpreters: _STDLIB_MODULE_NAMES = frozenset( getattr(sys, 'stdlib_module_names', {'builtins', 'collections', 'abc'}) ) If the __repr__-defining class's top-level module is not in that set, the object is treated as a value. Testing Added to test_components.py: ClassWithCustomRepr — overrides __repr__ only ClassWithCustomStr — overrides __str__ only (existing behaviour) fn_returning_custom_repr / fn_returning_custom_str — functions returning those objects Added to core_test.py: testPrintObjectWithCustomStr — existing __str__ path still works testPrintObjectWithCustomRepr — new __repr__ path: output is ClassWithCustomRepr(), not a help screen Run command: python3 -m pytest fire/ --ignore=fire/docstrings_fuzz_test.py --ignore=fire/parser_fuzz_test.py 262 tests pass, 0 failures. Checklist Fixes the reported issue Existing behaviour unchanged (no regressions — dict/list/OrderedDict still show help screens) Tests added All 262 tests pass Code style matches project conventions

Open Graph Description: Summary Fixes #595. Objects that override __repr__ but not __str__ (e.g. datasets.Dataset from HuggingFace) were shown as a help screen instead of being printed, because HasCustomStr only checked f...

X Description: Summary Fixes #595. Objects that override __repr__ but not __str__ (e.g. datasets.Dataset from HuggingFace) were shown as a help screen instead of being printed, because HasCustomStr only checked f...

Opengraph URL: https://github.com/google/python-fire/pull/653

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6244c7e6-6098-6ae5-7585-79c22a81c49a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9C58:16A191:31D500:4312A5:6A51BEE0
html-safe-nonce96a4db95d07f6d293270201efeb26fc78ce4d694b3da270faf5516ef628777e9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzU4OjE2QTE5MTozMUQ1MDA6NDMxMkE1OjZBNTFCRUUwIiwidmlzaXRvcl9pZCI6Ijg2MjUwNjc0NzM1MDk2NjI0MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacaa41cfddb26e7d5ab1e7f151530268e26013d9c4f73a477c7bb4571a96e01120
hovercard-subject-tagpull_request:3379894469
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/google/python-fire/pull/653/files
twitter:imagehttps://avatars.githubusercontent.com/u/33183708?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/33183708?s=400&v=4
og:image:altSummary Fixes #595. Objects that override __repr__ but not __str__ (e.g. datasets.Dataset from HuggingFace) were shown as a help screen instead of being printed, because HasCustomStr only checked f...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/google/python-fire git https://github.com/google/python-fire.git
octolytics-dimension-user_id1342004
octolytics-dimension-user_logingoogle
octolytics-dimension-repository_id82729529
octolytics-dimension-repository_nwogoogle/python-fire
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id82729529
octolytics-dimension-repository_network_root_nwogoogle/python-fire
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/google/python-fire/pull/653/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogle%2Fpython-fire%2Fpull%2F653%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
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
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
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/enterprise/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%2Fgoogle%2Fpython-fire%2Fpull%2F653%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=google%2Fpython-fire
Reloadhttps://github.com/google/python-fire/pull/653/files
Reloadhttps://github.com/google/python-fire/pull/653/files
Reloadhttps://github.com/google/python-fire/pull/653/files
Please reload this pagehttps://github.com/google/python-fire/pull/653/files
google https://github.com/google
python-firehttps://github.com/google/python-fire
Notifications https://github.com/login?return_to=%2Fgoogle%2Fpython-fire
Fork 1.5k https://github.com/login?return_to=%2Fgoogle%2Fpython-fire
Star 28.2k https://github.com/login?return_to=%2Fgoogle%2Fpython-fire
Code https://github.com/google/python-fire
Issues 131 https://github.com/google/python-fire/issues
Pull requests 52 https://github.com/google/python-fire/pulls
Actions https://github.com/google/python-fire/actions
Projects https://github.com/google/python-fire/projects
Security and quality 0 https://github.com/google/python-fire/security
Insights https://github.com/google/python-fire/pulse
Code https://github.com/google/python-fire
Issues https://github.com/google/python-fire/issues
Pull requests https://github.com/google/python-fire/pulls
Actions https://github.com/google/python-fire/actions
Projects https://github.com/google/python-fire/projects
Security and quality https://github.com/google/python-fire/security
Insights https://github.com/google/python-fire/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fgoogle%2Fpython-fire%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgoogle%2Fpython-fire%2Fissues%2Fnew%2Fchoose
shivamtiwari3https://github.com/shivamtiwari3
google:masterhttps://github.com/google/python-fire/tree/master
shivamtiwari3:fix/has-custom-str-reprhttps://github.com/shivamtiwari3/python-fire/tree/fix/has-custom-str-repr
Conversation 1 https://github.com/google/python-fire/pull/653
Commits 1 https://github.com/google/python-fire/pull/653/commits
Checks 1 https://github.com/google/python-fire/pull/653/checks
Files changed 3 https://github.com/google/python-fire/pull/653/files
Fix HasCustomStr to recognise custom __repr__ as a meaningful str (fixes #595) https://github.com/google/python-fire/pull/653/files#top
Show all changes 1 commit https://github.com/google/python-fire/pull/653/files
dd08ef3 Fix HasCustomStr to recognise custom __repr__ as a meaningful str shivamtiwari3 Mar 10, 2026 https://github.com/google/python-fire/pull/653/commits/dd08ef388d37f83b47f5e3a29beee770f4772bae
Clear filters https://github.com/google/python-fire/pull/653/files
Please reload this pagehttps://github.com/google/python-fire/pull/653/files
Please reload this pagehttps://github.com/google/python-fire/pull/653/files
core_test.py https://github.com/google/python-fire/pull/653/files#diff-bb54b89bfbfdb981ebb67bacb2d6223bf50845ba1b296708a1520e09f5bfd8d3
test_components.py https://github.com/google/python-fire/pull/653/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
value_types.py https://github.com/google/python-fire/pull/653/files#diff-b57542d4e50ebd4014e84247cc80cf46050c321746b674668d877253380776be
fire/core_test.pyhttps://github.com/google/python-fire/pull/653/files#diff-bb54b89bfbfdb981ebb67bacb2d6223bf50845ba1b296708a1520e09f5bfd8d3
View file https://github.com/google/python-fire/blob/dd08ef388d37f83b47f5e3a29beee770f4772bae/fire/core_test.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/google/python-fire/pull/653/{{ revealButtonHref }}
https://github.com/google/python-fire/pull/653/files#diff-bb54b89bfbfdb981ebb67bacb2d6223bf50845ba1b296708a1520e09f5bfd8d3
https://github.com/google/python-fire/pull/653/files#diff-bb54b89bfbfdb981ebb67bacb2d6223bf50845ba1b296708a1520e09f5bfd8d3
fire/test_components.pyhttps://github.com/google/python-fire/pull/653/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
View file https://github.com/google/python-fire/blob/dd08ef388d37f83b47f5e3a29beee770f4772bae/fire/test_components.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/google/python-fire/pull/653/{{ revealButtonHref }}
https://github.com/google/python-fire/pull/653/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
fire/value_types.pyhttps://github.com/google/python-fire/pull/653/files#diff-b57542d4e50ebd4014e84247cc80cf46050c321746b674668d877253380776be
View file https://github.com/google/python-fire/blob/dd08ef388d37f83b47f5e3a29beee770f4772bae/fire/value_types.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/google/python-fire/pull/653/{{ revealButtonHref }}
https://github.com/google/python-fire/pull/653/files#diff-b57542d4e50ebd4014e84247cc80cf46050c321746b674668d877253380776be
https://github.com/google/python-fire/pull/653/files#diff-b57542d4e50ebd4014e84247cc80cf46050c321746b674668d877253380776be
https://github.com/google/python-fire/pull/653/files#diff-b57542d4e50ebd4014e84247cc80cf46050c321746b674668d877253380776be
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.