-
Notifications
You must be signed in to change notification settings - Fork 26
Coding guidelines
Stephen A. Ramsey edited this page May 28, 2026
·
7 revisions
Apart from the requirements (already stated above) regarding static code checks for PEP8 compliance, type checking, and linting, there are some additional guidelines for coding changes on the ARAX code-base:
- If you are adding or modifying a line of code for debugging that will need
to be removed or updated before you commit, make sure you add a line comment
# :DEBUG:. This is important so you can ensure that debugging code doesn't leak through into the commit. - Please use modern type hints (from python3.10 or newer), so no uppercase
DictorList, and make sure to use| Noneinstead ofOptional. - Please review your code with a code LLM (e.g., Claude code or Copilot) to check for bugs before committing. Best results from LLM review seem to be when the LLM can see the code diffs in the context of the full ARAX code-base.
- Please visually inspect every line of your code diffs with
git diffbefore committing; this is the perfect opportunity to catch debug code (which would be indicated with a# :DEBUG:line comment) before it gets accidentally committed. - If you update the code in a function, it is best practice to bring it up
to modern standard in terms of type hinting and PEP8 formatting. But be
cautious about entirely reformatting (such as with
blackor whatever) a whole module for which another active-contributing team member has the vast majority of commits; check with her/him before making a major reformat. - If your code update introduces a new dependency on a PyPI distribution
package, it is critical that you update the ARAX
RTX/requirements.txtfile with the version-pinned dependency. You then need to test the updatedrequirements.txtfile, usingvenv/bin/pip install -r RTX/requirements.txt, to make sure it works as modified. If your code update introduces a dependency on a mypy types package liketypes-requestsor whatever, you need to put that inRTX/dev-requirements.txtas a pinned dependency and test it withpip. - All newly contributed python code from the OSU team should adhere to the PEP8 Style Guide for Python Code. Among other things, this means: No hard tabs; four space indentation; max 79 characters per line; proper use of CamelCase or snake_case or CAPS_SNAKE_CASE; proper use of whitespace around infix operators; etc.
- Where possible, try to minimize use of "path surgery", i.e.,
sys.path.append. Some path surgery is inevitable given the bifurcation of the code-base intoRTX/code/UI/OpenAPI/python-flask-serverandRTX/code/ARAXsubtrees, but please try to minimize it, bearing in mind that ARAX is run usingpython -mso it should be able to interpret dotted imports likefrom openapi_server.models.node import Node. - Lazy module import is to be avoided if at all possible, since ARAX runs in a multithreaded environment. This avoids nasty race conditions in the context of circular imports (see below), which is probably the main reason lazy import is used. It is strongly preferred to eagerly import modules when the application server is starting up in single-threaded mode. See ARAX issue 2788 for details.
- Circular module imports, while sometimes necessary, should be avoided if possible (requires at least one lazy import, and see item 1 above).