Documentation
¶
Overview ¶
Package python declares the Python language:
- its extensions, project manifests, comment forms and test files
- its visibility rule, which PEP 8 states
- its tree-sitter grammar and tags query
- pyright, its language server
A composition root calls Register, which adds Python to a registry and its engines to a catalogue.
Dependency position ¶
Imports the standard library, core/engine, core/sema, core/source, lang, lang/engines, lang/lsp, lang/treesitter and the tree-sitter grammar of Python. It does not import another language module.
Index ¶
Constants ¶
const Language source.Language = "python"
Language is the language this module declares. Every sema.ID of a Python declaration contains it, so a change invalidates the IDs an index has stored.
Variables ¶
This section is empty.
Functions ¶
func Declaration ¶
func Declaration() lang.Declaration
Declaration returns the declaration of Python, with the visibility rule of PEP 8 and the test files of pytest.
func Grammar ¶
func Grammar() treesitter.Grammar
Grammar returns the tree-sitter grammar of Python with the tags query of the module.
func IsTest ¶
IsTest reports whether p is a test file by the default patterns of pytest: a base name that starts with test_ or ends in _test.py.
func Register ¶
Register adds Python to r and its engines to c: the tree-sitter engine, and pyright for a workspace on disk.
func Server ¶
Server returns the declaration of pyright, the type checker of the Python extension of Visual Studio Code.
func Visibility ¶
func Visibility(name string) sema.Visibility
Visibility returns the visibility that PEP 8 gives a name. A leading underscore marks a name as internal, so Visibility returns sema.Unexported for it. A special name such as __init__ belongs to a protocol of the language, so Visibility returns sema.Exported for it, as for every other name. It returns sema.VisibilityUnknown for an empty name.
Types ¶
This section is empty.