diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bccb6f..c0a8de2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-toml - id: check-yaml @@ -12,7 +12,7 @@ repos: args: [--markdown-linebreak-ext=md] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.12.2 hooks: - - id: ruff + - id: ruff-check - id: ruff-format diff --git a/README.md b/README.md index d50f7b7..3bf4bfb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ Here is a quick rundown of what each file in this repository contains: - [`LICENSE.txt`](LICENSE.txt): [The MIT License](https://opensource.org/licenses/MIT), an OSS approved license which grants rights to everyone to use and modify your project, and limits your liability. We highly recommend you to read the license. - [`.gitignore`](.gitignore): A list of files and directories that will be ignored by Git. Most of them are auto-generated or contain data that you wouldn't want to share publicly. -- [`requirements-dev.txt`](requirements-dev.txt): Every PyPI package used for the project's development, to ensure a common development environment. More on that [below](#using-the-default-pip-setup). - [`pyproject.toml`](pyproject.toml): Configuration and metadata for the project, as well as the linting tool Ruff. If you're interested, you can read more about `pyproject.toml` in the [Python Packaging documentation](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/). - [`.pre-commit-config.yaml`](.pre-commit-config.yaml): The configuration of the [pre-commit](https://pre-commit.com/) tool. - [`.github/workflows/lint.yaml`](.github/workflows/lint.yaml): A [GitHub Actions](https://github.com/features/actions) workflow, a set of actions run by GitHub on their server after each push, to ensure the style requirements are met. @@ -82,7 +81,7 @@ It is *installed* by running `pre-commit install` and can be run manually by cal - `check-yaml`: Lints and corrects your YAML files. - `end-of-file-fixer`: Makes sure you always have an empty line at the end of your file. - `trailing-whitespace`: Removes whitespaces at the end of each line. -- `ruff`: Runs the Ruff linter. +- `ruff-check`: Runs the Ruff linter. - `ruff-format`: Runs the Ruff formatter. ## How do I use this template? @@ -106,12 +105,16 @@ One person in the team, preferably the leader, will have to create the repositor You are now ready to go! Sit down, relax, and wait for the kickstart! > [!IMPORTANT] -> Don't forget to swap "Python Discord" in the [`LICENSE.txt`](LICENSE.txt) file for the name of each of your team members or the name of your team *after* the start of the code jam. +> Don't forget to change the project name, description, and authors at the top of the [`pyproject.toml`](pyproject.toml) file, and swap "Python Discord" in the [`LICENSE.txt`](LICENSE.txt) file for the name of each of your team members or the name of your team *after* the start of the code jam. ### Using the default pip setup -Our default setup includes a bare requirements file to be used with a [virtual environment](https://docs.python.org/3/library/venv.html). -We recommend this if you have never used any other dependency manager, although if you have, feel free to switch to it. More on that [below](#how-do-i-adapt-this-template-to-my-project). +Our default setup includes a dependency group to be used with a [virtual environment](https://docs.python.org/3/library/venv.html). +It works with pip and uv, and we recommend this if you have never used any other dependency manager, although if you have, feel free to switch to it. +More on that [below](#how-do-i-adapt-this-template-to-my-project). + +Dependency groups are a relatively new feature, specified in [PEP 735](https://peps.python.org/pep-0735/). +You can read more about them in the [Python Packaging User Guide](https://packaging.python.org/en/latest/specifications/dependency-groups/). #### Creating the environment @@ -145,7 +148,7 @@ $ .venv/bin/Activate.ps1 Once the environment is created and activated, use this command to install the development dependencies. ```shell -pip install -r requirements-dev.txt +pip install --group dev ``` #### Exiting the environment @@ -163,11 +166,10 @@ Once the environment is activated, all the commands listed previously should wor ## How do I adapt this template to my project? -If you wish to use Pipenv or Poetry, you will have to move the dependencies in [`requirements-dev.txt`](requirements-dev.txt) to the development dependencies of your tool. +If you wish to use Pipenv or Poetry, you will have to move the dependencies in [`pyproject.toml`](pyproject.toml) to the development dependencies of your tool. -We've included a porting of [`requirements-dev.txt`](requirements-dev.txt) to both [Poetry](samples/pyproject.toml) and [Pipenv](samples/Pipfile) in the [`samples` folder](samples). -If you use the Poetry setup, make sure to change the project name, description, and authors at the top of the file. -Also note that the Poetry [`pyproject.toml`](samples/pyproject.toml) file does not include the Ruff configuration, so if you simply replace the file then the Ruff configuration will be lost. +We've included a porting to both [Poetry](samples/pyproject.toml) and [Pipenv](samples/Pipfile) in the [`samples` folder](samples). +Note that the Poetry [`pyproject.toml`](samples/pyproject.toml) file does not include the Ruff configuration, so if you simply replace the file then the Ruff configuration will be lost. When installing new dependencies, don't forget to [pin](https://pip.pypa.io/en/stable/topics/repeatable-installs/#pinning-the-package-versions) them by adding a version tag at the end. For example, if I wish to install [Click](https://click.palletsprojects.com/en/8.1.x/), a quick look at [PyPI](https://pypi.org/project/click/) tells me that `8.1.7` is the latest version. diff --git a/pyproject.toml b/pyproject.toml index 0880be9..6a232d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,25 @@ +[project] +# This section contains metadata about your project. +# Don't forget to change the name, description, and authors to match your project! +name = "code-jam-template" +description = "Add your description here" +authors = [ + { name = "Your Name" } +] +version = "0.1.0" +readme = "README.md" +requires-python = ">=3.12" +dependencies = [] + +[dependency-groups] +# This `dev` group contains all the development requirements for our linting toolchain. +# Don't forget to pin your dependencies! +# This list will have to be migrated if you wish to use another dependency manager. +dev = [ + "pre-commit~=4.2.0", + "ruff~=0.12.2", +] + [tool.ruff] # Increase the line length. This breaks PEP8 but it is way easier to work with. # The original reason for this limit was a standard vim terminal is only 79 characters, @@ -38,7 +60,4 @@ ignore = [ "TD002", "TD003", "FIX", - # Annotations. - "ANN101", - "ANN102", ] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index d529f2e..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -# This file contains all the development requirements for our linting toolchain. -# Don't forget to pin your dependencies! -# This list will have to be migrated if you wish to use another dependency manager. - -ruff~=0.5.0 -pre-commit~=3.7.1 diff --git a/samples/Pipfile b/samples/Pipfile index 27673c0..dedd0c5 100644 --- a/samples/Pipfile +++ b/samples/Pipfile @@ -8,8 +8,8 @@ name = "pypi" [packages] [dev-packages] -ruff = "~=0.5.0" -pre-commit = "~=3.7.1" +ruff = "~=0.12.2" +pre-commit = "~=4.2.0" [requires] python_version = "3.12" diff --git a/samples/pyproject.toml b/samples/pyproject.toml index 835045d..b486e50 100644 --- a/samples/pyproject.toml +++ b/samples/pyproject.toml @@ -11,8 +11,8 @@ license = "MIT" python = "3.12.*" [tool.poetry.dev-dependencies] -ruff = "~0.5.0" -pre-commit = "~3.7.1" +ruff = "~0.12.2" +pre-commit = "~4.2.0" [build-system] requires = ["poetry-core>=1.0.0"]