Title: **kwargs unexpectedly parses flags for later chained method · Issue #659 · google/python-fire · GitHub
Open Graph Title: **kwargs unexpectedly parses flags for later chained method · Issue #659 · google/python-fire
X Title: **kwargs unexpectedly parses flags for later chained method · Issue #659 · google/python-fire
Description: Suppose we have the following program from dataclasses import dataclass @dataclass class MyClass: x: int def transform(self, **kwargs): return MyClass(self.x * kwargs.get("multiplier", 2)) def do_something(self, msg): print(f"{msg}: {sel...
Open Graph Description: Suppose we have the following program from dataclasses import dataclass @dataclass class MyClass: x: int def transform(self, **kwargs): return MyClass(self.x * kwargs.get("multiplier", 2)) def do_s...
X Description: Suppose we have the following program from dataclasses import dataclass @dataclass class MyClass: x: int def transform(self, **kwargs): return MyClass(self.x * kwargs.get("multiplier", 2)...
Opengraph URL: https://github.com/google/python-fire/issues/659
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"**kwargs unexpectedly parses flags for later chained method","articleBody":"Suppose we have the following program\n\n```python\nfrom dataclasses import dataclass\n\n@dataclass\nclass MyClass:\n x: int\n\n def transform(self, **kwargs):\n return MyClass(self.x * kwargs.get(\"multiplier\", 2))\n\n def do_something(self, msg):\n print(f\"{msg}: {self.x}\")\n\nmy_obj = MyClass(3)\n```\n\nAnd we call it with `python -m fire my_module my_obj transform --multiplier=3 do_something --msg=\"test\"`, then the `--msg` is parsed when calling `transform` into the `kwargs` dict. Then it errors saying `--msg` is missing. Can we instead support parsing flags before the next chained method call? The kwargs is useful for example, to transform the object in ways that only implementation classes know what to do. \n\nMy current workarounds are (1) pass msg as positional arg to `do_something`, (2) have `do_something` take `**kwargs` and call `transform` within it. Neither is ideal as (1) would surprise anyone who uses my code and (2) adds extra plumbing that could be avoided.","author":{"url":"https://github.com/louis-shao","@type":"Person","name":"louis-shao"},"datePublished":"2026-04-03T21:43:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/659/python-fire/issues/659"}
| 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:d48fce78-eb90-9fe4-d354-091e2d10baa3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80AA:1485C9:43620E:5B6F57:6A4DA42E |
| html-safe-nonce | 63ed31921f221801eab6a17aa376faf0f8bc8419af4c70b7fc9de612163a77cf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEFBOjE0ODVDOTo0MzYyMEU6NUI2RjU3OjZBNERBNDJFIiwidmlzaXRvcl9pZCI6IjYxNzM2ODM2MzQ4NDAzODA0NjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2e13b7f97496329c5262bc8262d176564fd78d3bb9740a6c06d3a1af581e7d03 |
| hovercard-subject-tag | issue:4202306390 |
| 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/google/python-fire/659/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b8ef15f97bd4e510070ed1534e8d30c43b579587724919728da6c3592f136a2/google/python-fire/issues/659 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b8ef15f97bd4e510070ed1534e8d30c43b579587724919728da6c3592f136a2/google/python-fire/issues/659 |
| og:image:alt | Suppose we have the following program from dataclasses import dataclass @dataclass class MyClass: x: int def transform(self, **kwargs): return MyClass(self.x * kwargs.get("multiplier", 2)) def do_s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | louis-shao |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/google/python-fire git https://github.com/google/python-fire.git |
| octolytics-dimension-user_id | 1342004 |
| octolytics-dimension-user_login | |
| octolytics-dimension-repository_id | 82729529 |
| octolytics-dimension-repository_nwo | google/python-fire |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 82729529 |
| octolytics-dimension-repository_network_root_nwo | google/python-fire |
| 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 | 7f13faa65cccc9b729d674da83335d5dcfdfd193 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width