Skip to content

Commit

Permalink
Update makefile and use ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
M3t0r committed Aug 14, 2024
1 parent 8982955 commit 8dc816a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

18 changes: 8 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,33 @@ zipapp: $(DistFolder)/tpl

.PHONY: docker
docker: zipapp Dockerfile
docker build -t "tpl:v`./setup.py -V`" ./
docker build -t "tpl:v`rye version`" ./
@echo " ==>" `tput setaf 2`Succesfully`tput sgr0` build `tput setaf 4`$@`tput sgr0`.

.PHONY: wheel
wheel: $(DistFolder)/tpl.1
python3 ./setup.py sdist bdist_wheel
rye build --wheel --sdist
@echo " ==>" `tput setaf 2`Succesfully`tput sgr0` build `tput setaf 4`$@`tput sgr0`.

.PHONY: docs documentation
docs documentation: $(DistFolder)/tpl.1 $(BuildFolder)
@echo " ==>" `tput setaf 3`Building`tput sgr0` HTML documentation for `tput setaf 4;./setup.py -V;tput sgr0`
sphinx-build -j auto -d $(BuildFolder)/sphinx -b html docs $(DistFolder)/docs
rye run sphinx-build -j auto -d $(BuildFolder)/sphinx -b html docs $(DistFolder)/docs

$(DistFolder)/tpl.1: docs/manpage.rst
@# calling `./setup.py -V` makes sure that tpl.__version__ exists and docs/conf.py can import it
@echo " ==>" `tput setaf 3`Building`tput sgr0` manpage for `tput setaf 4;./setup.py -V;tput sgr0`
sphinx-build -d $(BuildFolder)/sphinx -b man -E docs $(DistFolder)
@echo " ==>" `tput setaf 3`Building`tput sgr0` manpage for `tput setaf 4;rye version;tput sgr0`
rye run sphinx-build -d $(BuildFolder)/sphinx -b man -E docs $(DistFolder)

.PHONY: test
test: TEST_SELECTOR ?= ""
test: codestyle
pytest -k ${TEST_SELECTOR} ./tests
rye run pytest -k ${TEST_SELECTOR} ./tests

.PHONY: codestyle
codestyle:
flake8 --max-line-length=88 tpl/
@# we have to ingore 401 and 811 because of the way that pytest
@# fixtures work
-flake8 --ignore=F401,F811 --max-line-length=88 tests/ && echo " ==>" Codestyle is `tput setaf 2`conforming`tput sgr0`.
rye run ruff check
@echo " ==>" Codestyle is `tput setaf 2`conforming`tput sgr0`.

.PHONY: all
all: test zipapp documentation # this is not all but the ones we recommend
Expand Down
9 changes: 5 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

# -- Project information -----------------------------------------------------

project = 'tpl'
copyright = '2018, Simon Lutz Brüggen'
author = 'Simon Lutz Brüggen'

from tpl.__version__ import __version__ as tpl_release_string

project = "tpl"
copyright = "2018, Simon Lutz Brüggen"
author = "Simon Lutz Brüggen"

# The short X.Y version
version, _, _ = tpl_release_string.partition("+")
# The full version, including alpha/beta/rc tags
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ version-file = "tpl/__version__.py"
[tool.rye]
managed = true
dev-dependencies = [
"flake8>=3.3",
"pytest>=3.4",
"sphinx",
"ruff>=0.5.7",
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = ["F401", "F811"] # pytest needs this

[tool.pytest.ini_options]
addopts = "-ra -q"
testpaths = [
Expand Down
6 changes: 3 additions & 3 deletions tpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ def merge_data(old: dict, new, array_key="_array_data", scalar_key="_scalar_data
already present. This also means that sub dicts in both values will get
merged.
"""
if type(new) == list:
if type(new) is list:
# if the new value is a list append it to the list element
old[array_key] = old.get(array_key, []) + new
return old

if type(new) != dict:
if type(new) is not dict:
# if the new value is not a dict use it as a scalar
old[scalar_key] = new
return old
Expand All @@ -146,7 +146,7 @@ def recursive_dict_merge(old: dict, new: dict):
for key, value in new.items():
if key not in old:
old[key] = value
elif type(old[key]) == dict and type(value) == dict:
elif type(old[key]) is dict and type(value) is dict:
recursive_dict_merge(old[key], value)
else:
old[key] = value
Expand Down

0 comments on commit 8dc816a

Please sign in to comment.