Skip to content

Conversation

@adrzewiecki
Copy link
Collaborator

Modern tooling - created by Astral

Hi again, hope this is welcome!

I have thought to update the template for a while (years..) but finally got around to it. If the changes are welcome i can help to update the guidelines.

It would also be useful if some of you want to test it out, and let me know if you have any problems.

All rulesets are for you to decide, but this could be a starting point.

uv - Python package management, written in Rust

Note

I assume you are still using conda/miniconda.

Even though conda can be used as a python package manager, pip would generally be a better options. An even better option is uv. It manages a lockfile, making it very easy to reproduce environments. Other tools like pipenv, poetry, pdm are also good options, but there is a reason that pdm itself adds support for uv.

uv is impressively fast and it feels like they actually want python development to be better.

Warning

It is important to note that uv also can manage environments, but they are not "mobile" in the same vain that conda environments are.

UV and Conda - 101

UV should be work well with conda environments, create and activate the environment as usual.

How you install uv is up to you, in the example below it is done by conda.

conda create --name <env-name> python=3.12 uv
conda activate  <env-name>

Add a package to the pyproject.toml

uv add ipykernel

Add a development package.

uv add ipykernel --dev

Update a package to the latest compatible version, based on the dependency tree.

uv lock --upgrade-package ipykernel

Install all packages from the lockfile.

uv sync

Note

If you want to install a package without changing the pyproject.toml or uv.lock.
uv pip install <package-name>

Ruff - Linter and Formatter

Faster and better formatter and linter

Replaces black, flake8, pydocstyle and docformatter.

These tools are built into ruff, making it very easy to enable and disable rules.

The configuration in this PR has enabled these rulesets:

I have ignored some rules that I have found to not be useful.

Pydocstyle config

Since we are using the google docstring style for pydocstyle the configuration looks a bit different then old pre-commit configuration.

Google style

These rules are disabled by default with google style and are thus not set explicitly in the new configuration.

  • D203
  • D213
  • D401
  • D406
  • D407
  • D413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant