Contributing#

All command lines in code block are run from root folder /

Installation#

  • You must have virtualenv

    pip install virtualenv # pip from python3.9 env you want
    
  • Python virtual environment

    ./config/install_venv39-dev.sh
    

Import system#

Import system can hide some sub-sub-…-modules hierarchy. Let us take as an example this files hierarchy:

.
└── src
    └── pkg_name
        ├── dir_a
        │   └── dir_a_1
        │       ├── __init__.py
        │       └── mod_a_1_1.py
        └── __init__.py

Module mod_a_1_1.py is too deep, we don’t want:

from pkg_name.dir_a.dir_a_1.mod_a_1_1 import ClassA11

but:

from pkg_name.dir_a import ClassA11

so,

  • __init__.py:

    import pkg_name.dir_a  # just import package namespace
    
  • dir_a_1/__init__.py:

    from pkg_name.dir_a.dir_a_1 import *
    
  • dir_a_1/__init__.py:

    from pkg_name.dir_a.dir_a_1.mod_a_1_1 import *
    

Testing#

Structure#

Folder structure must follow the way the user import. Example (see import system example):

.
└── tests
    ├── dir_a
    │   ├── __init__.py
    │   └── test_a_1_1.py
    ├── __init__.py
    └── conftest.py

In dir_a/test_a_1_1.py:

from typing import Iterator
import pytest
from pkg_name.dir_a import ClassA11

@pytest.fixture
def a_1_1_fixture() -> Iterator[ClassA11]:
    ...

def test_class_a_1_1(a_1_1_fixture: ClassA11):
    ...

In conftest.py:

# If one of the test modules want to use
#   the fixture defined in dir_a/test_a_1_1.py
from tests.dir_a.test_a_1_1 import a_1_1_fixture

Tox command#

tox -e report

Coverage#

After running the tox command, code coverage result appear in html files:

.
└── tests
    └── coverage
        ├── html
        │   ├── index.html
        │   └── ...
        ├── .coverage
        └── cov.xml

Just open coverage/html/index.hml file in internet navigator to visualise code coverage.

Documenting#

Import object#

All paths are those that the user will write.

In the example,

.. autoclass:: pkg_name.dir_a.ClassA11()
   :autosummary:
   :members:
   :undoc-members:
   :inherited-members:

Especially in docstrings:

"""A docstring.

:class:`~pkg_name.dir_a.ClassA11`
"""

Tox command#

tox -e docs-html

New version#

Change the version number in:

  • setup.cfg

Changelog#

Complete regularly CHANGELOG.md:

  • [Unreleased] section until new release

  • [M.m.p] section when decide to release a new version (M: Major, m: minor, p: patch)

See Keep a Changelog link for more details.

  • Added for new features.

  • Changed for changes in existing functionality.

  • Deprecated for soon-to-be removed features.

  • Removed for now removed features.

  • Fixed for any bug fixes.

  • Security in case of vulnerabilities.