From c9efc43c980dd7f0121c62ccb799520a6f8f27e5 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 19:54:45 -0700 Subject: [PATCH] aider: Added pyproject.toml file to configure black to use a maximum line length of 100 characters. # Context: USER: can i tell black to fix these automatically? ASSISTANT: Yes, you can use the `black` code formatter to automatically fix formatting issues in your Python files. To do this, you need to have `black` installed. If you don't have it installed, you can install it using pip: ``` pip install black ``` Once `black` is installed, you can run it on a specific file or directory to automatically format the code: ``` black aider/coder.py ``` This command will format the `aider/coder.py` file according to the `black` code style. If you want to format all the Python files in your project, you can run `black` on the project directory: ``` black . ``` This command will format all the Python files in the current directory and its subdirectories. USER: Please note that I shared content of these additional files: .pre-commit-config.yaml ASSISTANT: Yes, I see the content of the .pre-commit-config.yaml file. It shows that you have already configured pre-commit hooks for `black` and `flake8`. When you commit your changes, the pre-commit hooks will automatically run `black` to format your code and `flake8` to check for any linting issues. If there are any issues, the commit will be blocked, and you'll need to fix them before committing again. To run the pre-commit hooks manually without committing, you can use the following command: ``` pre-commit run --all-files ``` This command will run all the configured hooks on all the files in your repository. If there ^C KeyboardInterrupt USER: can we configure black to shorten lines to less than 100 chars so flake8 doesn't complain about E501 ASSISTANT: Yes, you can configure `black` to use a specific line length by adding a `pyproject.toml` file to your project's root directory with the desired line length setting. Here's how to create and configure the `pyproject.toml` file: ```toml pyproject.toml <<<<<<< ORIGINAL ======= [tool.black] line-length = 100 >>>>>>> UPDATED ``` This configuration sets the maximum line length for `black` to 100 characters, which will match the line length requirement of `flake8`. After adding this configuration, `black` will automatically format your code to keep lines within the specified limit. --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..aa4949aa1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 100