Editor Setup - efroemling/ballistica GitHub Wiki

Even though script code such as Python can be edited with nothing more than Notepad.exe, having a good set of tools to work with can make a huge difference. Ballistica aims to include a good set of command line tools as a foundation, but having a good editor/IDE set up can be even more beneficial.

This page is intended to cover specifics of using different editors with the project. If you have a favorite editor that works well with Python, feel free to add it here.

PyCharm

PyCharm by Jetbrains is a great Python IDE, and it should work 'out of the box' with the Ballistica project, as it is one of the primary ones I (Eric) use. The free community edition provides everything needed to work with the project. You should be able to simply open the Ballistica root directory in PyCharm and all paths/etc should be set up already. You may need to set up PyCharm's interpreter to match the one Ballistica expects. You can run tools/pcommand pyver in the project root dir to see what Python version Ballistica is currently targeting.

Here you can see the built-in error checking pointing out that a function-call does not exist. At the bottom you can also see the Mypy (Official) plugin on the left and the Pylint plugin on the right reporting the same thing.

Tips:

  • While you can run Mypy checks simply by going to the 'Terminal' tab and typing 'make mypy', it can be handy to use the Mypy (Official) plugin to get nice clickable errors/etc. To use it, search for it and install it via the preferences window. After installation you should see 'Mypy Terminal' tab at the bottom. Right click the background and go to 'Configure plugin...'. Now set 'Mypy command:' to 'make dmypy'. You may also need to set 'PATH suffix': to /usr/local/bin if you are on a Mac. You now should be able to see the same errors by hitting the 'Run' button in the Mypy Terminal that you see when you run 'make mypy'.

  • The Pylint plugin provides a similar setup for running pylint. You can run the same checks in the Terminal tab by typing 'make pylint', but using the plugin instead can give you nice clickable errors. Just search for and install it in the preferences window; you should not need to change any configuration. Note that 'make pylint' on the command line does some smart caching to avoid rechecking files that don't need it, but this plugin does not, so it can be quite slow if you poke the 'check project' button; you may want to limit yourself to 'check current file' or 'check module'.

Visual Studio Code

For modders

For using pylance in VSCode, we need to add our bombsquad/ba_data/python/ path in settings.json to python.analysis.extraPaths field. Press Ctrl + Shift + P then click Preferences:Open User settings (JSON)

{
    "security.workspace.trust.untrustedFiles": "open",
    "[python]": {
        "editor.formatOnType": true,
        "editor.defaultFormatter": "ms-python.black-formatter"
    },
    "python.defaultInterpreterPath": "C:\\Users\\rover\\AppData\\Local\\Programs\\Python\\Python311\\python.exe",
    "python.analysis.extraPaths": ["C:\\Users\\rover\\Desktop\\games\\BombSquad_Windows_1.7.24\\ba_data\\python"],

2023-07-29-040834_1920x1080_scrot

Additionally if you are working with internal modules then we have to generate dummy modules and append its path. Check Native Layer Overview for getting started with generating dummy modules

Emacs

I (Eric) also use Emacs for much of my work. Emacs is super old-school and very flexible but can require quite a bit of tinkering and work to set up some modern features such as code-completion or live error-checking. Some of my config files are already included with the project but I will try to post more relevant info here when possible. If you are an Emacs user, please let me know and I will hurry up :)


<< Native Layer Overview        Coding Style Guide >>