Created
September 3, 2025 17:11
-
-
Save Phrogz/7e77affeb361953c744f1b4e7fe06a15 to your computer and use it in GitHub Desktop.
Python project spoofing namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is in bar/__init__.py | |
| from proj.foo.bar.types import Message | |
| __all__ = ["Message"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is in bar/jim.py | |
| from proj.foo.bar import Message | |
| print(Message) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is in bar/types.py | |
| class Message: | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "folders": [ | |
| { | |
| "path": "." | |
| } | |
| ], | |
| "settings": { | |
| "cursorpyright.analysis.diagnosticMode": "openFilesOnly", | |
| "cursorpyright.analysis.typeCheckingMode": "standard", | |
| "files.trimTrailingWhitespace": true, | |
| "files.exclude": { | |
| ".pytest_cache": true, | |
| ".ruff_cache": true, | |
| ".venv": true, | |
| "**/__pycache__": true, | |
| "**/*.egg-info": true, | |
| }, | |
| "ruff.configuration": "pyproject.toml", | |
| "[python]": { | |
| "editor.codeActionsOnSave": { | |
| "source.fixAll": "never", | |
| "source.organizeImports.ruff": "explicit", | |
| "source.unusedImports": "never" | |
| }, | |
| "editor.defaultFormatter": "charliermarsh.ruff", | |
| "editor.formatOnSave": true, | |
| "editor.rulers": [160] // Visual indicator where Ruff source formatter breaks, see pyproject.toml for Ruff settings | |
| }, | |
| }, | |
| "extensions": { | |
| "recommendations": [ | |
| "anysphere.cursorpyright", // Using Cursor, not VS Code | |
| "charliermarsh.ruff", | |
| "ms-python.debugpy", | |
| "ms-python.python", | |
| "tamasfe.even-better-toml", | |
| ] | |
| }, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [project] | |
| name = "proj-foo" | |
| version = "1.0" | |
| description = "Standalone repo for foo" | |
| requires-python = "==3.11.*" | |
| [tool.ruff] | |
| line-length = 160 # Allow longer source lines than the default 88 chars | |
| exclude = [ ".venv/**" ] | |
| lint.select = [ "A", "ANN", "B", "C4", "D", "E", "F", "FA", "I", "PD", "PTH", "Q", "SIM", "TC", "UP" ] | |
| lint.pydocstyle.convention = "google" # Support Google-style docstrings | |
| [tool.pyproject-fmt] | |
| keep_full_version = true | |
| # Special configuration just for the foo-proj sub-repo. | |
| # This does not work, but indicates intent. | |
| [tool.uv.build-backend] | |
| module-root = "." | |
| module-name = "proj.foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment