From 17c8122d3a7e8db7becf4a0499316f14b3e213e9 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:33:02 -0700 Subject: [PATCH 01/11] Update pre-commit-hooks version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ff0ff1..75c5651 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 + rev: v4.5.0 hooks: - id: check-toml - id: check-yaml From 5b70abb324cf6655f21d10a7739cf598e4efb1fe Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:12:42 -0700 Subject: [PATCH 02/11] Replace flake8 and isort with ruff --- .pre-commit-config.yaml | 21 ++-------- pyproject.toml | 42 ++++++++++++++++++++ dev-requirements.txt => requirements-dev.txt | 9 +---- samples/Pipfile | 9 +---- samples/pyproject.toml | 10 +---- tox.ini | 33 --------------- 6 files changed, 52 insertions(+), 72 deletions(-) create mode 100644 pyproject.toml rename dev-requirements.txt => requirements-dev.txt (53%) delete mode 100644 tox.ini diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 75c5651..9b77e7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,6 @@ ## Pre-commit setup # See https://github.com/python-discord/code-jam-template/tree/main#pre-commit-run-linting-before-committing -# Make sure to edit the `additional_dependencies` list if you want to add plugins - repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 @@ -13,19 +11,8 @@ repos: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.5.1 - hooks: - - id: python-check-blanket-noqa - - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - - - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 hooks: - - id: flake8 - additional_dependencies: - - flake8-docstrings~=1.6.0 + - id: ruff + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2581acb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[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, +# but this doesn't really apply anymore. +line-length = 119 +# Target Python 3.12. If you decide to use a different version of Python +# you will need to update this value. +target-version = "py312" +# Automatically fix auto-fixable issues. +fix = true +# The directory containing the source code. If you choose a different project layout +# you will need to update this value. +src = ["src"] + +[tool.ruff.lint] +# Enable all linting rules. +select = ["ALL"] +# Ignore some of the most obnoxious linting errors. +ignore = [ + # Missing docstrings. + "D100", + "D104", + "D105", + "D106", + "D107", + # Docstring whitespace. + "D203", + "D213", + # Docstring quotes. + "D301", + # Builtins. + "A", + # Print statements. + "T20", + # TODOs. + "TD002", + "TD003", + "FIX", + # Annotations. + "ANN101", + "ANN102", +] diff --git a/dev-requirements.txt b/requirements-dev.txt similarity index 53% rename from dev-requirements.txt rename to requirements-dev.txt index 829a816..327dc21 100644 --- a/dev-requirements.txt +++ b/requirements-dev.txt @@ -2,10 +2,5 @@ # Don't forget to pin your dependencies! # This list will have to be migrated if you wish to use another dependency manager. -# Base tools -flake8~=4.0.1 -isort~=5.10.1 -pre-commit~=2.17.0 - -# Flake8 plugins, see https://github.com/python-discord/code-jam-template/tree/main#plugin-list -flake8-docstrings~=1.6.0 +ruff~=0.3.5 +pre-commit~=3.7.0 diff --git a/samples/Pipfile b/samples/Pipfile index a12d251..c5ee7ad 100644 --- a/samples/Pipfile +++ b/samples/Pipfile @@ -6,13 +6,8 @@ name = "pypi" [packages] [dev-packages] -# Base tools -flake8 = "~=4.0.1" -isort = "~=5.12.0" -pre-commit = "~=2.17.0" - -# Flake8 plugins, see https://github.com/python-discord/code-jam-template/tree/main#plugin-list -flake8-docstrings = "~=1.6.0" +ruff = "~=0.3.5" +pre-commit = "~=3.7.0" [requires] python_version = "3.10" diff --git a/samples/pyproject.toml b/samples/pyproject.toml index db63ac4..3de3ea9 100644 --- a/samples/pyproject.toml +++ b/samples/pyproject.toml @@ -9,14 +9,8 @@ license = "MIT" python = "3.10.*" [tool.poetry.dev-dependencies] -# Base tools -flake8 = "~4.0.1" -isort = "~5.12.0" -pre-commit = "~2.17.0" - -# Flake8 plugins, see https://github.com/python-discord/code-jam-template/tree/main#plugin-list -flake8-docstrings = "~1.6.0" - +ruff = "~0.3.5" +pre-commit = "~3.7.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tox.ini b/tox.ini deleted file mode 100644 index bbb3c7a..0000000 --- a/tox.ini +++ /dev/null @@ -1,33 +0,0 @@ -# Flake8 and ISort configuration - -[flake8] -# 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, -# but this doesn't really apply anymore. -max-line-length=119 -# Don't lint the venv or the CPython cache. -exclude=.venv,__pycache__ -# Ignore some of the most obnoxious linting errors. -ignore= - W503,E226, - # Missing Docstrings - D100,D104,D105,D106,D107, - # Docstring Whitespace - D203,D212,D214,D215, - # Docstring Quotes - D301,D302, - # Docstring Content - D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417, - # Comments - E266 - -[isort] -# Select the 5th style (Hanging grid grouped) to handle longer import. -# This choice is mostly arbitrary and can be changed at your will. -# -# Example of this style: -# from third_party import ( -# lib1, lib2, lib3, lib4, -# lib5, ... -# ) -multi_line_output=5 From 6467281dc1098e6c797192f7348c74bc74192666 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:13:37 -0700 Subject: [PATCH 03/11] Update Python version to 3.12 --- .github/workflows/lint.yaml | 2 +- samples/Pipfile | 2 +- samples/pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 13851d0..4967274 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -19,7 +19,7 @@ jobs: env: # The Python version your project uses. Feel free to change this if required. - PYTHON_VERSION: "3.10" + PYTHON_VERSION: "3.12" steps: # Checks out the repository in the current folder. diff --git a/samples/Pipfile b/samples/Pipfile index c5ee7ad..f978a99 100644 --- a/samples/Pipfile +++ b/samples/Pipfile @@ -10,4 +10,4 @@ ruff = "~=0.3.5" pre-commit = "~=3.7.0" [requires] -python_version = "3.10" +python_version = "3.12" diff --git a/samples/pyproject.toml b/samples/pyproject.toml index 3de3ea9..781a273 100644 --- a/samples/pyproject.toml +++ b/samples/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Author 1 "] license = "MIT" [tool.poetry.dependencies] -python = "3.10.*" +python = "3.12.*" [tool.poetry.dev-dependencies] ruff = "~0.3.5" From 95f2aa48f0e0bad7d4b15d756594eaec7519de42 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:14:13 -0700 Subject: [PATCH 04/11] Update CI github actions --- .github/workflows/lint.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4967274..5f033c7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,15 +22,13 @@ jobs: PYTHON_VERSION: "3.12" steps: - # Checks out the repository in the current folder. - - name: Checks out repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 - # Set up the right version of Python - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - name: Run pre-commit hooks - uses: pre-commit/action@v3.0.0 + uses: pre-commit/action@v3.0.1 From 7b0b37cf59e4fe9d3638a3aa14d5845d223ca4f1 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:15:00 -0700 Subject: [PATCH 05/11] Clean up comments --- .github/workflows/lint.yaml | 3 ++- .pre-commit-config.yaml | 2 +- samples/Pipfile | 2 ++ samples/pyproject.toml | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5f033c7..7f67e80 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,4 +1,4 @@ -# GitHub Action Workflow enforcing our code style. +# GitHub Action workflow enforcing our code style. name: Lint @@ -9,6 +9,7 @@ on: branches: - main pull_request: + # Brand new concurrency setting! This ensures that not more than one run can be triggered for the same commit. # It is useful for pull requests coming from the main repository since both triggers will match. concurrency: lint-${{ github.sha }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b77e7e..6de6102 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -## Pre-commit setup +# Pre-commit configuration. # See https://github.com/python-discord/code-jam-template/tree/main#pre-commit-run-linting-before-committing repos: diff --git a/samples/Pipfile b/samples/Pipfile index f978a99..82b8e15 100644 --- a/samples/Pipfile +++ b/samples/Pipfile @@ -1,3 +1,5 @@ +# Sample Pipfile. + [[source]] url = "https://pypi.org/simple" verify_ssl = true diff --git a/samples/pyproject.toml b/samples/pyproject.toml index 781a273..4d54252 100644 --- a/samples/pyproject.toml +++ b/samples/pyproject.toml @@ -1,7 +1,9 @@ +# Sample poetry configuration. + [tool.poetry] name = "Name" version = "0.1.0" -description = "" +description = "Description" authors = ["Author 1 "] license = "MIT" From 057f4d239bed9a6724c6104ab11b4c438c11bc79 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:24:47 -0700 Subject: [PATCH 06/11] Rename LICENSE to LICENSE.txt --- LICENSE => LICENSE.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE.txt (100%) diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt From bf560ade51a169d30084d7318cc903f9a3d6ec1d Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:25:07 -0700 Subject: [PATCH 07/11] Bump dependency versions --- .pre-commit-config.yaml | 4 ++-- requirements-dev.txt | 4 ++-- samples/Pipfile | 4 ++-- samples/pyproject.toml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6de6102..c57d163 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.5.0 + rev: v4.6.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.3.5 + rev: v0.4.10 hooks: - id: ruff - id: ruff-format diff --git a/requirements-dev.txt b/requirements-dev.txt index 327dc21..dfc76ab 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,5 +2,5 @@ # Don't forget to pin your dependencies! # This list will have to be migrated if you wish to use another dependency manager. -ruff~=0.3.5 -pre-commit~=3.7.0 +ruff~=0.4.10 +pre-commit~=3.7.1 diff --git a/samples/Pipfile b/samples/Pipfile index 82b8e15..b013419 100644 --- a/samples/Pipfile +++ b/samples/Pipfile @@ -8,8 +8,8 @@ name = "pypi" [packages] [dev-packages] -ruff = "~=0.3.5" -pre-commit = "~=3.7.0" +ruff = "~=0.4.10" +pre-commit = "~=3.7.1" [requires] python_version = "3.12" diff --git a/samples/pyproject.toml b/samples/pyproject.toml index 4d54252..19dbea8 100644 --- a/samples/pyproject.toml +++ b/samples/pyproject.toml @@ -11,8 +11,8 @@ license = "MIT" python = "3.12.*" [tool.poetry.dev-dependencies] -ruff = "~0.3.5" -pre-commit = "~3.7.0" +ruff = "~0.4.10" +pre-commit = "~3.7.1" [build-system] requires = ["poetry-core>=1.0.0"] From a3b49aca592a8b725efe277ce1c9c9bc47bea854 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:28:01 -0700 Subject: [PATCH 08/11] Update README --- README.md | 156 +++++++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 4ef088b..6c41821 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,46 @@ # Python Discord Code Jam Repository Template -## A Primer +## A primer + Hello code jam participants! We've put together this repository template for you to use in [our code jams](https://pythondiscord.com/events/) or even other Python events! -This document will contain the following information: +This document contains the following information: + 1. [What does this template contain?](#what-does-this-template-contain) -2. [How do I use it?](#how-do-i-use-it) -3. [How do I adapt it to my project?](#how-do-i-adapt-it-to-my-project) +2. [How do I use this template?](#how-do-i-use-this-template) +3. [How do I adapt this template to my project?](#how-do-i-adapt-this-template-to-my-project) -You can also look at [our style guide](https://pythondiscord.com/events/code-jams/code-style-guide/) to get more information about what we consider a maintainable code style. +> [!TIP] +> You can also look at [our style guide](https://pythondiscord.com/events/code-jams/code-style-guide/) to get more information about what we consider a maintainable code style. ## What does this template contain? Here is a quick rundown of what each file in this repository contains: -- `LICENSE`: [The MIT License](https://opensource.org/licenses/MIT), an OSS approved license which grants rights to everyone to use and modify your projects and limits your liability. We highly recommend you to read the license. -- `.gitignore`: A list of files that will be ignored by Git. Most of them are auto-generated or contain data that you wouldn't want to share publicly. -- `dev-requirements.txt`: Every PyPI packages used for the project's development, to ensure a common and maintainable code style. [More on that below](#using-the-default-pip-setup). -- `tox.ini`: The configurations of two of our style tools: [`flake8`](https://pypi.org/project/flake8/) and [`isort`](https://pypi.org/project/isort/). -- `.pre-commit-config.yaml`: The configuration of the [`pre-commit`](https://pypi.org/project/pre-commit/) tool. -- `.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. + +- [`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. Each of these files have comments for you to understand easily, and modify to fit your needs. -### flake8: general style rules +### Ruff: general style rules + +Our first tool is Ruff. It will check your codebase and warn you about any non-conforming lines. +It is run with the command `ruff check` in the project root. -Our first and probably most important tool is flake8. It will run a set of plugins on your codebase and warn you about any non-conforming lines. Here is a sample output: -``` -~> flake8 -./app.py:1:6: N802 function name 'helloWorld' should be lowercase -./app.py:1:16: E201 whitespace after '(' -./app.py:2:1: D400 First line should end with a period -./app.py:2:1: D403 First word of the first line should be properly capitalized -./app.py:3:19: E225 missing whitespace around operator + +```shell +$ ruff check +app.py:1:5: N802 Function name `helloWorld` should be lowercase +app.py:1:5: ANN201 Missing return type annotation for public function `helloWorld` +app.py:2:5: D400 First line should end with a period +app.py:2:5: D403 First word of the first line should be capitalized: `docstring` -> `Docstring` +app.py:3:15: W292 No newline at end of file +Found 5 errors. ``` Each line corresponds to an error. The first part is the file path, then the line number, and the column index. @@ -40,90 +48,83 @@ Then comes the error code, a unique identifier of the error, and then a human-re If, for any reason, you do not wish to comply with this specific error on a specific line, you can add `# noqa: CODE` at the end of the line. For example: + ```python def helloWorld(): # noqa: N802 ... -``` -will pass linting. Although we do not recommend ignoring errors unless you have a good reason to do so. - -It is run by calling `flake8` in the project root. -#### Plugin List: +``` -- `flake8-docstring`: Checks that you properly documented your code. +This will ignore the function naming issue and pass linting. -### ISort: automatic import sorting +> [!WARNING] +> We do not recommend ignoring errors unless you have a good reason to do so. -This second tool will sort your imports according to the [PEP8](https://www.python.org/dev/peps/pep-0008/#imports). That's it! One less thing for you to do! +### Ruff: formatting -It is run by calling `isort .` in the project root. Notice the dot at the end, it tells ISort to use the current directory. +Ruff also comes with a formatter, which can be run with the command `ruff format`. +It follows the same code style enforced by [Black](https://black.readthedocs.io/en/stable/index.html), so there's no need to pick between them. ### Pre-commit: run linting before committing -This third tool doesn't check your code, but rather makes sure that you actually *do* check it. +The second tool doesn't check your code, but rather makes sure that you actually *do* check it. It makes use of a feature called [Git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) which allow you to run a piece of code before running `git commit`. -The good thing about it is that it will cancel your commit if the lint doesn't pass. You won't have to wait for Github Actions to report and have a second fix commit. +The good thing about it is that it will cancel your commit if the lint doesn't pass. You won't have to wait for GitHub Actions to report issues and have a second fix commit. It is *installed* by running `pre-commit install` and can be run manually by calling only `pre-commit`. [Lint before you push!](https://soundcloud.com/lemonsaurusrex/lint-before-you-push) -#### Hooks List: +#### List of hooks - `check-toml`: Lints and corrects your TOML files. - `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-whitespaces`: Removes whitespaces at the end of each line. -- `python-check-blanket-noqa`: Forbids you from using noqas on large pieces of code. -- `isort`: Runs ISort. -- `flake8`: Runs flake8. +- `trailing-whitespace`: Removes whitespaces at the end of each line. +- `ruff`: Runs the Ruff linter. +- `ruff-format`: Runs the Ruff formatter. -## How do I use it? +## How do I use this template? -### Creating your Team Repository +### Creating your team repository One person in the team, preferably the leader, will have to create the repository and add other members as collaborators. 1. In the top right corner of your screen, where **Clone** usually is, you have a **Use this template** button to click. - -![](https://docs.github.com/assets/images/help/repository/use-this-template-button.png) - + ![use-this-template-button](https://docs.github.com/assets/images/help/repository/use-this-template-button.png) 2. Give the repository a name and a description. - -![](https://docs.github.com/assets/images/help/repository/create-repository-name.png) - + ![create-repository-name](https://docs.github.com/assets/images/help/repository/create-repository-name.png) 3. Click **Create repository from template**. - 4. Click **Settings** in your newly created repository. - -![](https://docs.github.com/assets/images/help/repository/repo-actions-settings.png) - + ![repo-actions-settings](https://docs.github.com/assets/images/help/repository/repo-actions-settings.png) 5. In the "Access" section of the sidebar, click **Collaborators**. - -![Screenshot from 2023-08-28 14-09-55](https://github.com/python-discord/code-jam-template/assets/63936253/c150110e-d1b5-4e4d-93e0-0a2cf1de352b) - + ![collaborators-settings](https://github.com/python-discord/code-jam-template/assets/63936253/c150110e-d1b5-4e4d-93e0-0a2cf1de352b) 6. Click **Add people**. - 7. Insert the names of each of your teammates, and invite them. Once they have accepted the invitation in their email, they will have write access to the repository. -You are now ready to go! Now sit down, relax, and wait for the kickstart! -Don't forget to swap "Python Discord" in the `LICENSE` file for the name of each of your team members or the name of your team after the start of the jam. +You are now ready to go! Sit down, relax, and wait for the kickstart! -### Using the Default Pip Setup +> [!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. -Our default setup includes a bare requirement file to be used with a [virtual environment](https://docs.python.org/3/library/venv.html). +### Using the default pip setup -We recommend this if you never have used any other dependency manager, although if you have, feel free to switch to it. More on that below. +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). #### Creating the environment + Create a virtual environment in the folder `.venv`. + ```shell -$ python -m venv .venv +python -m venv .venv ``` -#### Enter the environment +#### Entering the environment + It will change based on your operating system and shell. + ```shell # Linux, Bash $ source .venv/bin/activate @@ -139,35 +140,44 @@ $ .venv/bin/Activate.ps1 > .venv\Scripts\Activate.ps1 ``` -#### Installing the Dependencies +#### Installing the dependencies + Once the environment is created and activated, use this command to install the development dependencies. + ```shell -$ pip install -r dev-requirements.txt +pip install -r requirements-dev.txt ``` #### Exiting the environment -Interestingly enough, it is the same for every platform + +Interestingly enough, it is the same for every platform. + ```shell -$ deactivate +deactivate ``` -Once the environment is activated, all the commands listed previously should work. We highly recommend that you run `pre-commit install` as soon as possible. +Once the environment is activated, all the commands listed previously should work. + +> [!IMPORTANT] +> We highly recommend that you run `pre-commit install` as soon as possible. -## How do I adapt it to my project? +## 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 `dev-requirements.txt` to the development dependencies of your tool. +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. -We've included a porting of `dev-requirements.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. +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. -When installing new dependencies, don't forget to [pin them](https://pip.pypa.io/en/stable/user_guide/#pinned-version-numbers) by adding a version tag at the end. -For example, if I wish to install `Click`, a quick look at [PyPI](https://pypi.org/project/click/) tells me that 8.0.1 is the latest version. -I will then add `click ~= 8.0`, without the last number, to my dependency manager. +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. +I will then add `click~=8.1`, without the last number, to my requirements file or dependency manager. -A code jam project is left unmaintained after the end of the event. If the dependencies aren't pinned, the project will break after the first major change in an API. +> [!IMPORTANT] +> A code jam project is left unmaintained after the end of the event. If the dependencies aren't pinned, the project will break after any major change in an API. ## Final words -Don't forget to replace this README with an actual description of your project! Images are also welcome! +> [!IMPORTANT] +> Don't forget to replace this README with an actual description of your project! Images are also welcome! We hope this template will be helpful. Good luck in the jam! From c45ca524739e29cba130b7b1001cdc4352956222 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:28:23 -0700 Subject: [PATCH 09/11] Ignore redundant docstring lint rule --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2581acb..0880be9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,8 @@ ignore = [ # Docstring whitespace. "D203", "D213", + # Docstring punctuation. + "D415", # Docstring quotes. "D301", # Builtins. From 298dfdea3594c495c0598d5b43e8e2a7947e49ec Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Sun, 30 Jun 2024 00:41:07 -0700 Subject: [PATCH 10/11] Bump Ruff to v0.5.0 --- .pre-commit-config.yaml | 2 +- requirements-dev.txt | 2 +- samples/Pipfile | 2 +- samples/pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c57d163..4bccb6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: args: [--markdown-linebreak-ext=md] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.10 + rev: v0.5.0 hooks: - id: ruff - id: ruff-format diff --git a/requirements-dev.txt b/requirements-dev.txt index dfc76ab..d529f2e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,5 +2,5 @@ # Don't forget to pin your dependencies! # This list will have to be migrated if you wish to use another dependency manager. -ruff~=0.4.10 +ruff~=0.5.0 pre-commit~=3.7.1 diff --git a/samples/Pipfile b/samples/Pipfile index b013419..27673c0 100644 --- a/samples/Pipfile +++ b/samples/Pipfile @@ -8,7 +8,7 @@ name = "pypi" [packages] [dev-packages] -ruff = "~=0.4.10" +ruff = "~=0.5.0" pre-commit = "~=3.7.1" [requires] diff --git a/samples/pyproject.toml b/samples/pyproject.toml index 19dbea8..835045d 100644 --- a/samples/pyproject.toml +++ b/samples/pyproject.toml @@ -11,7 +11,7 @@ license = "MIT" python = "3.12.*" [tool.poetry.dev-dependencies] -ruff = "~0.4.10" +ruff = "~0.5.0" pre-commit = "~3.7.1" [build-system] From 7c1b9c48611fc42a642c326f11f30774ee6273a4 Mon Sep 17 00:00:00 2001 From: Lemonyte <49930425+lemonyte@users.noreply.github.com> Date: Sat, 6 Jul 2024 23:52:43 -0700 Subject: [PATCH 11/11] Add note about Poetry config --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6c41821..d50f7b7 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ If you wish to use Pipenv or Poetry, you will have to move the dependencies in [ 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. 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.