Development#

Here are a few notes about the development process. Useful links:

Linting#

The top-level Makefile provides a few linting-related target, leveraging some of the most-widely used linters and static code analyzers.

all: ruff flake lint

flake:
	flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
	flake8 astropix_analysis bin tests --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics

ruff:
	ruff check astropix_analysis bin tests

lint:
	pylint astropix_analysis bin tests \
		--disable too-many-ancestors \
		--disable too-many-arguments \
		--disable too-many-function-args \
		--disable too-many-instance-attributes \
		--disable c-extension-no-member \
		--disable use-dict-literal \
		--disable too-many-positional-arguments \
		--disable too-many-public-methods \
		--disable too-many-lines

While sticking to any coding convention is not a goal, per se, running statick checks on the code helps early identifications of potential problems. If you just run

make

you will have a concise summary of the linting output.

Note

We do run

` flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics `

in our continuos integration on github, so the latter will fail in case of severe problems, including

  • E9: Syntax Errors and Indentation Errors

  • F63: Incomplete or Invalid Comprehension Targets

  • F7: Forward Reference or Late Binding Issues

  • F82: Undefined Name in __all__

If and when we get particularly good at this we can include more check in the continuous integration, but for the moment we stick to a relaxed mood.

Unit tests#

All the unit tests are in the tests folder, and we use pytest to run them.

You trigger the unit tests locally by doing

make test

In addition, we have

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.7", "3.13"]

    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        sudo apt-get install -y libegl1
        python -m pip install --upgrade pip
        python -m pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
        pip install -e .
    - name: Lint with flake8
      run: |
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
    - name: Test with pytest
      run: |
        pytest

Documentation#

All the documentation lives in docs and leverages the sphinx system.

You trigger the compilation of the documentation locally by doing

make html

(The static html output lives in docs/_build/html/.)