Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mypy to pre-commit hooks, change ruff to automated fixing #249

Merged
merged 6 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ repos:
rev: v0.9.2
hooks:
- id: ruff
args: [ check ]
args: [ --fix ]
- id: ruff-format
args: [ --check ]

- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.0.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: [ --verbose ]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
entry: mypy fluster/ scripts/
pass_filenames: false
args: [ --strict, --no-warn-unused-ignores, --ignore-missing-imports, --explicit-package-bases ]
19 changes: 3 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
PY_FILES=fluster scripts
CONTRIB_DIR=contrib
DECODERS_DIR=decoders
PYTHONPATH=.
Expand All @@ -14,9 +13,9 @@ help:
@awk -F ':|##' '/^[^\t].+?:.*?##/ { printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF }' $(MAKEFILE_LIST)

install_deps: ## install Python dependencies
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements-dev.txt

check: lint-check ## check that very basic tests run
check: ## check that very basic tests run
@echo "Running dummy test..."
$(FLUSTER) list
$(FLUSTER) list -c
Expand Down Expand Up @@ -50,18 +49,6 @@ ifneq ($(OS),Windows_NT)
endif
@echo "\nAll test finished succesfully!"

format: ## format python code
@echo "Formatting coding style with ruff..."
ruff format $(PY_FILES)

lint: ## run static python code analysis - fix issues (manual fix, complements pre-commit)
@echo "Linting and fixing issues with ruff... "
ruff check --fix $(PY_FILES)

lint-check: ## run static python code analysis - does not apply fixes
@echo "Checking static types with mypy..."
mypy --strict $(PY_FILES)

create_dirs=mkdir -p $(CONTRIB_DIR) $(DECODERS_DIR)

all_reference_decoders: h264_reference_decoder h265_reference_decoder h266_reference_decoder mpeg_2_aac_reference_decoder mpeg_4_aac_reference_decoder ## build all reference decoders
Expand Down Expand Up @@ -195,4 +182,4 @@ dbg-%:
echo "Value of $* = $($*)"

.PHONY: help all_reference_decoders h264_reference_decoder h265_reference_decoder h266_reference_decoder\
mpeg_4_aac_reference_decoder mpeg_2_aac_reference_decoder check format lint lint-check install_deps clean
mpeg_4_aac_reference_decoder mpeg_2_aac_reference_decoder check install_deps clean
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ suites.
## Description

Fluster requires **Python 3.6+** to work. It has zero dependencies apart from
that. The [requirements.txt](https://github.com/fluendo/fluster/blob/master/requirements.txt) file includes Python's modules
that. The [requirements-dev.txt](https://github.com/fluendo/fluster/blob/master/requirements-dev.txt) file includes Python's modules
used only for development.

The framework works with test suites. Each test suite is associated with one
Expand Down Expand Up @@ -595,7 +595,7 @@ results are obtained, we can do the following procedure:

1. Fork the repo.
2. Install the required Python modules for development using `pip3 install -r
requirements.txt`.
requirements-dev.txt`.
3. Install the [git hook](https://github.com/fluendo/fluster/blob/master/scripts/install_git_hook.sh) that will run for every
commit to ensure it works before pushing. [About git
hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ build-backend = "setuptools.build_meta"

[project]
name = "fluster-conformance"
version = "0.2.0" # TODO: Ensure that version 0.2.0 is marked as the final version in the CI release workflow only when we are certain about deploying a new release. This prevents creating an irreversible history in PyPI, which would block re-uploading the same version.
# TODO: Ensure that version 0.x.0 is marked as the final version in the CI release workflow only when we are certain
# about deploying a new release. This prevents creating an irreversible history in PyPI, which would block re-uploading
# the same version.
version = "0.2.0"
authors = [
{name = "Andoni Morales Alastruey", email="amorales@fluendo.com"},
# {name = "Pablo Marcos Oltra"}, wait to (https://github.com/pypi/warehouse/issues/12877)
Expand Down Expand Up @@ -95,11 +98,9 @@ packages = ["fluster", "fluster.decoders"]
"test_suites/vp9/VP9-TEST-VECTORS.json"
]

[project.optional-dependencies]
dev = [
"ruff",
"mypy"
]
# Once https://github.com/pypa/pip/issues/12963 is implemented we can think about adding
# [dependency-groups]
# dev = ["pre-commit==2.21.0"]

# https://docs.astral.sh/ruff/configuration/#configuring-ruff
[tool.ruff]
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pre-commit==2.21.0
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.