Title: Maybe __all__ should be added explicitly in stubgen · Issue #10314 · python/mypy · GitHub
Open Graph Title: Maybe __all__ should be added explicitly in stubgen · Issue #10314 · python/mypy
X Title: Maybe __all__ should be added explicitly in stubgen · Issue #10314 · python/mypy
Description: Feature (A clear and concise description of your feature proposal.) Maybe __all__ should be added explicitly in stubgen. Pitch (Please explain why this feature should be implemented and how it would be used. Add examples, if applicable.)...
Open Graph Description: Feature (A clear and concise description of your feature proposal.) Maybe __all__ should be added explicitly in stubgen. Pitch (Please explain why this feature should be implemented and how it woul...
X Description: Feature (A clear and concise description of your feature proposal.) Maybe __all__ should be added explicitly in stubgen. Pitch (Please explain why this feature should be implemented and how it woul...
Opengraph URL: https://github.com/python/mypy/issues/10314
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Maybe __all__ should be added explicitly in stubgen","articleBody":"**Feature**\r\n\r\n(A clear and concise description of your feature proposal.)\r\n\r\nMaybe `__all__` should be added explicitly in stubgen.\r\n\r\n**Pitch**\r\n\r\n(Please explain why this feature should be implemented and how it would be used. Add examples, if applicable.)\r\n\r\nAdding `__all__` to type stubs explicitly can avoid some error. For example:\r\n\r\n├── test\r\n│ └── __init__.py\r\n\r\n\r\n\\_\\_init\\_\\_.py:\r\n```python\r\nclass Test:\r\n pass\r\n\r\n__all__ = []\r\n```\r\n\r\nThe type stub file generated by stubgen is\r\n\\_\\_init\\_\\_.pyi:\r\n```python\r\nclass Test: ...\r\n```\r\n\r\nWhen using `from .test import *` to import test as a submodule, `Test` will be imported according to the type stub, while in fact `Test` should not be used.\r\n\r\n**A Possible Implement**\r\n\r\nReplace `output(self)` in stubgen.py by following implement:\r\n```python\r\n def output(self) -> str:\r\n \"\"\"Return the text for the stub.\"\"\"\r\n imports = ''\r\n if self._import_lines:\r\n imports += ''.join(self._import_lines)\r\n imports += ''.join(self.import_tracker.import_lines())\r\n if imports and self._output:\r\n imports += '\\n'\r\n imports += ''.join(self._output)\r\n \"\"\"export __all__ when it's defined\"\"\"\r\n if imports and self._all_ != None:\r\n imports += '\\n'\r\n if self._all_ != None:\r\n imports += '__all__ = ['\r\n for name in self._all_:\r\n imports += ''.join(('\\\"', name, '\\\", '))\r\n imports += ']'\r\n return imports\r\n```","author":{"url":"https://github.com/wrvsrx","@type":"Person","name":"wrvsrx"},"datePublished":"2021-04-12T08:58:58Z","url":"https://github.com/python/mypy/issues/10314"}
| 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:ca0b1f00-d91d-617c-012c-c463ac88d9a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D44:120A77:1D8C0F5:2810197:6B000FFE |
| html-safe-nonce | bbee5bbcf67479ba23aab9a377defcacad31068178afacd3d0218efd9a0f7561 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDQ0OjEyMEE3NzoxRDhDMEY1OjI4MTAxOTc6NkIwMDBGRkUiLCJ2aXNpdG9yX2lkIjoiNTQ3MTMxNjg5NTUxODk1MzQ3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cba3a271d917570e96eff726fb4d2d96a5d5bc213de9b69b876e059fa510abd3 |
| hovercard-subject-tag | issue:855734661 |
| 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/python/mypy/10314/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23d6278483228c1db71ac618bb1ee3eb86dac0214d2819d16af993c9e212d84b/python/mypy/issues/10314 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23d6278483228c1db71ac618bb1ee3eb86dac0214d2819d16af993c9e212d84b/python/mypy/issues/10314 |
| og:image:alt | Feature (A clear and concise description of your feature proposal.) Maybe __all__ should be added explicitly in stubgen. Pitch (Please explain why this feature should be implemented and how it woul... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wrvsrx |
| hostname | github.com |
| expected-hostname | github.com |
| None | cf7ee0062053ad9eb05b6e5de57bd96c2055708bcbada4144946b5ec129cf1d7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 9cab7de176a56362d2aabcbb4d1e07e846eba8a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width