Registry / serialization / tree-sitter-powershell

tree-sitter-powershell

JSON →
library0.26.4pypypi✓ verified 72d ago

A PowerShell grammar for tree-sitter, providing robust parsing of PowerShell scripts (including PowerShell 5.1 and PowerShell 7+). Current version 0.26.4, requires Python >=3.10. Released from https://github.com/airbus-cert/tree-sitter-powershell.

pip install tree-sitter-powershell
INSTALL
IMPORT
SIG · TREE-SITTER-POWERS
T
tree-sitter-powershell
serializationpythonv0.26.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

language
from tree_sitter_powershell import language
from tree_sitter_powershell import Language
In v0.20+, the grammar exposes 'language' directly, not a Language class.

Parses a PowerShell snippet and prints the s-expression of the AST.

from tree_sitter import Language, Parser from tree_sitter_powershell import language PS_LANGUAGE = Language(language()) parser = Parser(PS_LANGUAGE) tree = parser.parse(b"Write-Host 'Hello, World!'") print(tree.root_node.sexp())
Debug
Known issues
gotchaThe grammar object is a callable that returns a language pointer. Use `language()` (not just `language`) when passing to `Language()` constructor.
fix
Use `Language(language())` instead of `Language(language)`.
affects: >=0.20.0
breakingIn version 0.20+, the import path changed: `from tree_sitter_powershell import language` replaces the old `from tree_sitter_powershell import Language` (where Language was a class).
fix
Update imports to `from tree_sitter_powershell import language`.
affects: >=0.20.0
deprecatedThe old `Language` class from tree-sitter-powershell <=0.19 is deprecated and may be removed.
fix
Upgrade to >=0.20.0 and use the new `language()` function.
affects: <=0.19
Errors
Common errors & fixes
TypeError: expected Language, got function
Passing the `language` function directly to `Language()` instead of calling it.
fix
Use `Language(language())`.
ImportError: cannot import name 'Language' from 'tree_sitter_powershell'
The `Language` class was removed in v0.20+.
fix
Use `from tree_sitter_powershell import language` and then `Language(language())`.
Upgrade
Version history
0.26.4latest on PyPI · released May 4, 2026
Audit
Dependencies
tree-sitterrequiredRuntime dependency for tree-sitter bindings
Agent activity
362 hits · last 30 days
node
339
Amazon
1
Perplexity
1
Google (AI)
1
OpenAI (training)
1
Resources