Title: Using `--help` with `file.Fire()` usage incorrectly prints imports and variables · Issue #220 · google/python-fire · GitHub
Open Graph Title: Using `--help` with `file.Fire()` usage incorrectly prints imports and variables · Issue #220 · google/python-fire
X Title: Using `--help` with `file.Fire()` usage incorrectly prints imports and variables · Issue #220 · google/python-fire
Description: When running --help against a program like the following, I expect a single my_func command but instead I get my_func, fire, logging, GREETING_MSG, and logger. I would like to be able to ignore python module imports and local variables b...
Open Graph Description: When running --help against a program like the following, I expect a single my_func command but instead I get my_func, fire, logging, GREETING_MSG, and logger. I would like to be able to ignore pyt...
X Description: When running --help against a program like the following, I expect a single my_func command but instead I get my_func, fire, logging, GREETING_MSG, and logger. I would like to be able to ignore pyt...
Opengraph URL: https://github.com/google/python-fire/issues/220
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using `--help` with `file.Fire()` usage incorrectly prints imports and variables","articleBody":"When running `--help` against a program like the following, I expect a single `my_func` command but instead I get `my_func`, `fire`, `logging`, `GREETING_MSG`, and `logger`. I would like to be able to ignore python module imports and local variables by default.\r\n\r\n```python\r\nimport fire\r\nimport logging\r\n\r\nGREETING_MSG = \"Hello\"\r\n\r\nlogger = logging.get_logger()\r\n\r\ndef _my_internal_hidden_func():\r\n # This is correctly ignored\r\n pass\r\n\r\ndef my_func():\r\n logger.info(f\"{GREETING_MSG}, world\")\r\n\r\nif __name__ = \"__main__\":\r\n fire.Fire()\r\n```\r\n\r\nFor the simple example above, the obvious resolution is to use a different method of invoking `Fire()` but for my actual use case, there are over 40 functions in the file I want to expose. For internal functions, I can hide these simply be preceeding the name with underscore, but I don't see any similar way of suppressing the imports and variable definitions.\r\n\r\nI'd propose resolving this in one of two ways:\r\n (1) Add some kind of heuristic to the default fire.Fire() invocation to ignore imports and variables\r\n (2) Add some type of flags and/or lambda function support so the code consuming Fire can customize this logic without having to create and directly pass a custom dictionary of all functions.\r\n\r\nIs anything like this already in progress, and/or would something along these lines be accepted as a pull request?\r\n\r\nThanks!","author":{"url":"https://github.com/aaronsteers","@type":"Person","name":"aaronsteers"},"datePublished":"2020-02-18T05:44:23Z","url":"https://github.com/google/python-fire/issues/220"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:aedf0593-c052-a3c9-5e6a-711594870e0e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E63E:23D776:86ACC2:AFB2AA:6AFFE3E7 |
| html-safe-nonce | e04e0a67b56a82237e647407840ffd3a9c8d88f1ac84e5207c0652a6e8a4f8ff |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjNFOjIzRDc3Njo4NkFDQzI6QUZCMkFBOjZBRkZFM0U3IiwidmlzaXRvcl9pZCI6IjcxODI4NjgzNjM3NzE2MzQ2NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 841075106b3bcdad77cd3c9b2ddbeb6771ea1bc888b835504a3dd3e35e2f6e8d |
| hovercard-subject-tag | issue:566661640 |
| 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/220/issue_layout |
| twitter:image | https://opengraph.githubassets.com/804c8ad33e37b965ddad31a8a378ac3b9745ef637c276c88fd1e590f9e591a03/google/python-fire/issues/220 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/804c8ad33e37b965ddad31a8a378ac3b9745ef637c276c88fd1e590f9e591a03/google/python-fire/issues/220 |
| og:image:alt | When running --help against a program like the following, I expect a single my_func command but instead I get my_func, fire, logging, GREETING_MSG, and logger. I would like to be able to ignore pyt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aaronsteers |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width