# run tests
test:
	hatch run default:python -m unittest tests/test*.py

# for development: check typing error and fix them if possible
fix: test
	hatch run dev:ruff format
	hatch run dev:ruff check --fix
	hatch run dev:ty check

# for development: check typing error without fixing anything
check: test
	hatch run dev:ruff check
	hatch run dev:ty check

# generate stubs
stubs:
	rm -rf typings/
	hatch run stubs:stubgen -p galaxy_graph --output=typings

# update the package
update: && uninstall install test
	git pull
	hatch env prune

# install the package in the current environment
install: test
	python -m pip install . -e

# uninstall the package from the current environment
uninstall:
	python -m pip uninstall modularity-graph

# for development: build release
build: check
	hatch build

# for development: delete files created by build
clean-build: build
	rm -rf dist

# for development: publish release to pypi and my own package registry
publish: build && clean-build
	hatch publish
	hatch publish -r https://git.linarphy.net/api/packages/linarphy/pypi/ || true

# for development: main command to run after a code change
release: && publish
	jj bookmark advance
	jj git push --all
	./hooks/post-commit
