Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom configs #16

Merged
merged 5 commits into from
Jun 1, 2023
Merged

Add custom configs #16

merged 5 commits into from
Jun 1, 2023

Conversation

turnerm
Copy link
Member

@turnerm turnerm commented May 26, 2023

More custom configs. A couple of issues to note:

  • I had to separate black and ruff configurations, because the formats of the files need to be different unfortunately
  • I cannot for the life of me figure out if there is a way to use a custom path to hatch.toml. There is a --config option for hatch but it's more for the general configuration file config.toml. I can keep searching / experimenting, as this would really pare down pyrpoject.toml

@turnerm turnerm requested a review from mcarans May 26, 2023 16:10
@github-actions
Copy link

github-actions bot commented May 26, 2023

Test Results

0 tests   - 95   0 ✔️  - 95   0s ⏱️ - 2m 30s
0 suites  -   1   0 💤 ±  0 
0 files    -   1   0 ±  0 

Results for commit eb7ab99. ± Comparison against base commit 66e9930.

♻️ This comment has been updated with latest results.

@mcarans
Copy link
Contributor

mcarans commented May 29, 2023

Thanks for your work on this.

I have made an issue for Hatch about using a .config folder: pypa/hatch#867. The author responded "Top-level --config https://hatch.pypa.io/latest/cli/reference/" which sounds like you've tried. if --config does not work as you'd expect, please can you reply to the issue say why it is unsuitable or let me know so I can.

In ruff documentation it says "As an alternative to pyproject.toml, Ruff will also respect a ruff.toml (or .ruff.toml) file, which implements an equivalent schema (though the [tool.ruff] hierarchy can be omitted)." (https://beta.ruff.rs/docs/configuration/#using-rufftoml)

It says can be omitted. Did you find that the [tool.ruff] hierarchy must be omitted? If so, please can you create an issue on the ruff project to get this clarified.

I think the # build section that has [tool.hatch.build. can be moved to just below

#########################
# Project Configuration #
#########################

This is so that the Hatch stuff is consecutive in the pyproject.toml file. What do you think?

@turnerm
Copy link
Member Author

turnerm commented May 30, 2023

Thanks for looking into all of that Mike.

I have made an issue for Hatch about using a .config folder: pypa/hatch#867. The author responded "Top-level --config https://hatch.pypa.io/latest/cli/reference/" which sounds like you've tried. if --config does not work as you'd expect, please can you reply to the issue say why it is unsuitable or let me know so I can.

Ah great to open a discussion. I think the confusion comes from the fact that --config is for a general Hatch configuration, as mentioned here.

In the local section it says: "By default, Hatch will look for a pyproject.toml file in the current working directory and any parent directories. The directory storing the first found file will be considered the project root.". This makes me think that the project configuration must be in the project root - I will mention this in the discussion.

In ruff documentation it says "As an alternative to pyproject.toml, Ruff will also respect a ruff.toml (or .ruff.toml) file, which implements an equivalent schema (though the [tool.ruff] hierarchy can be omitted)." (https://beta.ruff.rs/docs/configuration/#using-rufftoml)

It says can be omitted. Did you find that the [tool.ruff] hierarchy must be omitted? If so, please can you create an issue on the ruff project to get this clarified.

Ah nice find, indeed I confirmed that with ruff.toml the headings do not work, I've opened this issue

This is so that the Hatch stuff is consecutive in the pyproject.toml file. What do you think?

Good idea, I've reorganized pyproject.toml a bit, let me know what you think.

@mcarans
Copy link
Contributor

mcarans commented May 31, 2023

I like the reorganised pyproject.toml!

What happens if you include the lines below in ruff.toml - does ruff complain about unknown configuration? If you point Black at it, does Black complain about the ruff config?

[tool.black]
line-length = 79

Hopefully soon, Black won't be needed as its functionality will be in ruff.

@turnerm
Copy link
Member Author

turnerm commented May 31, 2023

If I try to add the black parameters to ruff.toml as you suggested, ruff complains:

error: Failed to parse `/home/turnerm/sync/hdx-python-utilities/.config/ruff.toml`: TOML parse error at line 16, column 2
   |
16 | [tool.black]
   |  ^^^^
unknown field `tool`, expected one of `allowed-confusables`, `builtins`, `cache-dir`, `dummy-variable-rgx`, `exclude`, `extend`, `extend-exclude`, `extend-ignore`, `extend-select`, `external`, `fix`, `fix-only`, `fixable`, `format`, `force-exclude`, `ignore`, `ignore-init-module-imports`, `line-length`, `required-version`, `respect-gitignore`, `select`, `show-source`, `show-fixes`, `src`, `namespace-packages`, `target-version`, `task-tags`, `typing-modules`, `unfixable`, `update-check`, `flake8-annotations`, `flake8-bandit`, `flake8-bugbear`, `flake8-builtins`, `flake8-comprehensions`, `flake8-errmsg`, `flake8-quotes`, `flake8-self`, `flake8-tidy-imports`, `flake8-type-checking`, `flake8-gettext`, `flake8-implicit-str-concat`, `flake8-import-conventions`, `flake8-pytest-style`, `flake8-unused-arguments`, `isort`, `mccabe`, `pep8-naming`, `pycodestyle`, `pydocstyle`, `pylint`, `pyupgrade`, `per-file-ignores`

but black does not seem to mind.

Copy link
Contributor

@mcarans mcarans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking. These changes all look fine to me.

@turnerm turnerm merged commit fd42c79 into main Jun 1, 2023
@turnerm turnerm deleted the more-custom-config branch June 1, 2023 07:07
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.

2 participants