Skip to content

Commit

Permalink
Linter/Formatter updatests
Browse files Browse the repository at this point in the history
- Added Error suffix to all exceptions as well
- Removed exceptions module in cfdp
  • Loading branch information
robamu committed Nov 27, 2024
1 parent de5c764 commit e8c44e8
Show file tree
Hide file tree
Showing 93 changed files with 1,489 additions and 1,672 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -23,23 +23,23 @@ jobs:
run: |
python3 -m pip install --upgrade pip setuptools wheel
pip install .
- name: Build documentation and examples
run: |
pip install -r docs/requirements.txt
sphinx-build -b html docs docs/_build
sphinx-build -b doctest docs docs/_build
- name: Lint with Ruff
uses: chartboost/ruff-action@v1
uses: astral-sh/ruff-action@v1

- name: Run tests and generate coverage data
run: |
python3 -m pip install coverage pytest
coverage run -m pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

# [unreleased]

# [v0.26.0] 2024-11-27

## Changed

- `MetadataPdu` options have to be specified as an optional list of abstract TLVs now.
A new getter method `options_as_tlv` can be used to retrieve a list of concrete TLV objects.
- All exceptions has an `*Error` suffix now
- Removed `exceptions` module in CFDP and moved it to individual `defs` definition modules.
The Errors can still be directly imported from `spacepackets.cfdp` or `spacepackets.cfdp.tlv`.

## Fixed

- `CrcError` exception constructor was previously named `__int__` by accident.

# [v0.25.0] 2024-10-29

## Changed
Expand Down
1 change: 1 addition & 0 deletions docs/api/ccsds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CCSDS Package
:members:
:undoc-members:
:show-inheritance:
:no-index:

Spacepacket Module
-------------------------------------
Expand Down
11 changes: 2 additions & 9 deletions docs/api/cfdp.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CFDP Package
CFDP Package
==========================

Package Contents
Expand All @@ -8,6 +8,7 @@ Package Contents
:members:
:undoc-members:
:show-inheritance:
:no-index:

PDU Submodule
----------------
Expand Down Expand Up @@ -43,11 +44,3 @@ Common Definitions
:members:
:undoc-members:
:show-inheritance:

Exceptions
-------------------------------------

.. automodule:: spacepackets.cfdp.exceptions
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/api/cfdp_tlv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CFDP Type-Length-Value (TLV) Subpackage
:members:
:undoc-members:
:show-inheritance:
:no-index:

Definitions Module
--------------------
Expand Down
1 change: 1 addition & 0 deletions docs/api/ecss.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ECSS Package
:members:
:undoc-members:
:show-inheritance:
:no-index:

.. automodule:: spacepackets.ecss.defs
:members:
Expand Down
74 changes: 70 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ build-backend = "setuptools.build_meta"
name = "spacepackets"
description = "Various CCSDS and ECSS packet implementations"
readme = "README.md"
version = "0.25.0"
requires-python = ">=3.8"
version = "0.26.0"
requires-python = ">=3.9"
license = {text = "Apache-2.0"}
authors = [
{name = "Robin Mueller", email = "[email protected]"}
Expand Down Expand Up @@ -38,7 +38,73 @@ dependencies = [
[tool.setuptools.packages]
find = {}

[tool.ruff]
exclude = [
".git",
"venv",
"docs"
]
line-length = 100

[tool.ruff.lint]
ignore = ["E501"]
select = [
# See https://docs.astral.sh/ruff/rules/
"F", # pyflakes
"E", # pycodestyle
"W", # pycodestyle
"I", # isort
"N", # pep8-naming
# "D", # pydocstyle (documentation!)
"ANN", # flake8-annotations
"UP", # pyupgrade
"ASYNC", # flake8-async
"S", # flake8-bandit
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TID", # flake8-tidy
"TCH", # flake8-type-checking
"PERF", # Performance
"FURB", # Refurb rules
"PL", # Pylint
"RUF" # ruff specific
]
ignore = [
"S101", # Use of assert, should be changed in the future
"ANN204", # Do not use return typing on __init__, __new__ and __call__ methods
"E111", # Recommended to be disabled when using the ruff formatter
"E114", # Recommended to be disabled when using the ruff formatter
"PLR2004" # This lint is a bit too conservative. Not every number needs to be a named constant.
]

[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["F401"]
"tests/*" = [
"INP001", # Tests are implicit namespace packets
"S101", # Tests use assert
"S105", # Tests use hardcoded test credentials
"S108", # Tests use temporary files names
"S311", # Tests use random without cryptographic security requirements
"ANN", # Type hints in test are not required
"PLR0912", # Too many branches
"PLR0915", # Too many statements
"PLR2004", # Magic values in comparison are common in tests
"D" # No documentation rules in tests
]
"examples/*" = [
"INP001", # Examples are implicit namespace packets
"S101", # Examples use assert
"S104", # Possible binding to all interfaces
"S108", # Temp files
"PLR0915" # Too many statements
]

[tool.ruff.lint.pylint]
max-args = 10
2 changes: 1 addition & 1 deletion release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The steps shown here are for Ubuntu/MacOS.
3. Update `CHANGELOG.md`: Convert `unreleased` section into version section
with date and new `unreleased`section.
4. Run tests with `pytest .`
5. Run auto-formatter with `black .`
5. Run auto-formatter with `ruff format .`
6. Run linter with `ruff check .`
7. Wait for CI/CD results. This also runs the tests on different operating systems

Expand Down
16 changes: 12 additions & 4 deletions spacepackets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import logging

from spacepackets.ccsds import (
SpacePacketHeader,
SpHeader,
SpacePacket,
PacketType,
SequenceFlags,
SpacePacket,
SpacePacketHeader,
SpHeader,
)

from spacepackets.exceptions import BytesTooShortError

__all__ = [
"BytesTooShortError",
"PacketType",
"SequenceFlags",
"SpHeader",
"SpacePacket",
"SpacePacketHeader",
]

__LIB_LOGGER = logging.getLogger(__name__)

Expand Down
27 changes: 20 additions & 7 deletions spacepackets/ccsds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
"""This package contains all CCSDS related components"""

from .spacepacket import (
SpHeader,
SpacePacketHeader,
SpacePacket,
PacketType,
SequenceFlags,
SPACE_PACKET_HEADER_SIZE,
AbstractSpacePacket,
PacketId,
PacketSeqCtrl,
AbstractSpacePacket,
SPACE_PACKET_HEADER_SIZE,
PacketType,
SequenceFlags,
SpacePacket,
SpacePacketHeader,
SpHeader,
get_total_space_packet_len_from_len_field,
)
from .time import * # noqa: F403 # re-export

__all__ = [
"SPACE_PACKET_HEADER_SIZE",
"AbstractSpacePacket",
"PacketId",
"PacketSeqCtrl",
"PacketType",
"SequenceFlags",
"SpHeader",
"SpacePacket",
"SpacePacketHeader",
"get_total_space_packet_len_from_len_field",
]
Loading

0 comments on commit e8c44e8

Please sign in to comment.