Skip to main content

Independent set of tools for working with GDScript - parser, linter and formatter

Project description

GDScript Toolkit

License: MIT Code style: black

This project provides a set of tools for daily work with GDScript. At the moment it provides:

  • A parser that produces a parse tree for debugging and educational purposes.
  • A linter that performs a static analysis according to some predefined configuration.
  • A formatter that formats the code according to some predefined rules.
  • A code metrics calculator which calculates cyclomatic complexity of functions and classes.


To install this project you need python3 and pip. Regardless of the target version, installation is done by pip3 command and for stable releases, it downloads the package from PyPI.

Godot 4

pip3 install "gdtoolkit==4.*"

Godot 3

pip3 install "gdtoolkit==3.*"

master (latest)

Latest version (potentially unstable) can be installed directly from git:

pip3 install git+

Linting with gdlint (more)

To run a linter you need to execute gdlint command like:

$ gdlint misc/

Which outputs messages like:

misc/ Error: Function argument name "aOrigin" is not valid (function-argument-name)
misc/ Error: Function argument name "aPos" is not valid (function-argument-name)

Formatting with gdformat (more)

Formatting may lead to data loss, so it's highly recommended to use it along with Version Control System (VCS) e.g. git

To run a formatter you need to execute gdformat on the file you want to format. So, given a file:

class X:
	var x=[1,2,{'a':1}]
	var y=[1,2,3,]     # trailing comma
	func foo(a:int,b,c=[1,2,3]):
		if a in c and \
		   b > 100:
func bar():

when you execute gdformat command, the file will be reformatted as follows:

class X:
	var x = [1, 2, {'a': 1}]
	var y = [
	]  # trailing comma

	func foo(a: int, b, c = [1, 2, 3]):
		if a in c and b > 100:

func bar():

Parsing with gdparse (more)

To run a parser you need to execute the gdparse command like:

gdparse tests/valid-gd-scripts/ -p

The parser outputs a tree that represents your code's structure:

      signal_stmt	sss
      signal_stmt	sss

Calculating cyclomatic complexity with gdradon

To run cyclomatic complexity calculator you need to execute the gdradon command like:

gdradon cc tests/formatter/input-output-pairs/ tests/gd2py/input-output-pairs/

The command outputs calculated metrics just like Radon cc command does for Python code:

    C 1:0 X - A (2)
    F 2:1 foo - A (1)
    F 22:0 foo - A (1)
    F 24:0 bar - A (1)
    C 18:0 C - A (1)
    F 1:0 foo - B (8)

Development (more)

Everyone is free to fix bugs or introduce new features. For that, however, please refer to existing issue or create one before starting implementation.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gdtoolkit-4.0.1.tar.gz (40.9 kB view hashes)

Uploaded source

Built Distribution

gdtoolkit-4.0.1-py3-none-any.whl (55.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page