Skip to content

Development

John Giorgi edited this page Jul 24, 2019 · 2 revisions

Code Style Guide

This project follows the Google Style Guide for Python with few exceptions. Other things of note:

  • We use the flake8 linter. On VSCode, this can be selected/installed by opening the command palate and choosing: Python: Select Linter > flake8.
  • We set a maximum line length of 100. The tox.ini file in this packages repository specifies this, overwriting flake8's default line length (79).
  • In VSCode, you can install autoDocstring and select Google in Docstring Format to automatically fill in docstrings formatted according to the Google Style Guide.

Refactoring

Import statements

Import statements are automatically sorted using isort. If you are using VSCode, isort is included under the python extension. Simply open the command palette and select: Python Refactor: Sort Imports.

Commit Messages

Besides the usual best practices for git commit messages, feel free to add an emjoi to the beginning of the commit message according to these guidelines.

Unit Testing, Code Review, and Continous Integration

We use pytest as our unit testing framework and tox to manage testing and for checking our package against best practices. Additionally, we use TravisCI for continuous integration and Codacy for automated code reviews.

To run a complete check on the package (which includes unit tests, and checking the package structure and manifest file), simply call tox from the root of the package directory

$ git clone https://github.com/berc-uoft/Transformer-GCN-QA.git
$ cd Transformer-GCN-QA
$ tox

Unit Tests

Unit tests are organized under src/tests. We use the unit test framework pytest. Each file under src/tests should begin with test_*.py and unit tests should be organized as methods with names def test_* under a class. This allows all tests to be automatically discovered by pytest. You can read more about the pytest framework here.

conftest.py

In src/tests/conftest.py, you should place any pytest fixtures that are used in the unit tests. These fixtures will be available to the classes and methods under src/tests/test_*.py. You can read more about pytest fixtures here.