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

refactor: Split CliSettings from Settings #1891

Merged
merged 2 commits into from
Jan 15, 2023

Conversation

not-my-profile
Copy link
Contributor

No description provided.

We want to automatically derive Hash for the library settings, which
requires us to split off all the settings unused by the library
(since these shouldn't affect the hash used by ruff_cli::cache).
@@ -12,6 +12,7 @@ use globset::{Glob, GlobMatcher, GlobSet};
use itertools::Either::{Left, Right};
use itertools::Itertools;
use once_cell::sync::Lazy;
#[cfg(test)]
Copy link
Member

Choose a reason for hiding this comment

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

Is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes the import is only used in the test-only for_rule(s) functions and omitting this attribute results in clippy complaining about an unused import. An alternative would be to move the import into the functions but I don't really see the benefit.

pub fn from_configuration(config: Configuration, project_root: &Path) -> Result<Self> {
Ok(Self {
cli: CliSettings {
cache_dir: config
Copy link
Member

Choose a reason for hiding this comment

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

Should we impl From<&Configuration>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd have to get rid of the additional project_root parameter ... I am not sure if that's desirable.

#[derive(Debug)]
pub struct AllSettings {
pub cli: CliSettings,
pub lib: Settings,
Copy link
Member

Choose a reason for hiding this comment

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

Idly wondering if this should be LibSettings, and AllSettings should be Settings.

Copy link
Member

Choose a reason for hiding this comment

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

Eh, AllSettings or CombinedSettings is probably for the aggregate struct. Although I do wonder if Settings should be LibSettings or something.

Copy link
Contributor Author

@not-my-profile not-my-profile Jan 15, 2023

Choose a reason for hiding this comment

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

I don't think CliSettings belongs in the ruff crate at all ... my plan is to move it to ruff_cli in the future. So I think it makes sense to keep it as Settings since these ought to be the only settings in the library crate.

If it turns out that we cannot move CliSettings I am alright with changing Settings to LibSettings but I'd like to try that factorisation first (at some point in the future after this PR has been merged).

@charliermarsh charliermarsh merged commit d75d6d7 into astral-sh:main Jan 15, 2023
renovate bot referenced this pull request in ixm-one/pytest-cmake-presets Jan 16, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.222` ->
`^0.0.223` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.223/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.223/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.223/compatibility-slim/0.0.222)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.223/confidence-slim/0.0.222)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.223`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.223)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.222...v0.0.223)

#### What's Changed

- Turn define_rule_mapping! into a procedural macro by
[@&#8203;not-my-profile](https://togithub.com/not-my-profile) in
[https://github.com/charliermarsh/ruff/pull/1885](https://togithub.com/charliermarsh/ruff/pull/1885)
- Convert confusable violations to named fields by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1887](https://togithub.com/charliermarsh/ruff/pull/1887)
- Add a dedicated token indexer for continuations and comments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1886](https://togithub.com/charliermarsh/ruff/pull/1886)
- Remove some Clippy allows by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1888](https://togithub.com/charliermarsh/ruff/pull/1888)
- Update add plugin/rule scripts by
[@&#8203;messense](https://togithub.com/messense) in
[https://github.com/charliermarsh/ruff/pull/1889](https://togithub.com/charliermarsh/ruff/pull/1889)
- Improve magic value message wording by
[@&#8203;TomFryers](https://togithub.com/TomFryers) in
[https://github.com/charliermarsh/ruff/pull/1892](https://togithub.com/charliermarsh/ruff/pull/1892)
- Use more precise error ranges for RET505~508 by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1895](https://togithub.com/charliermarsh/ruff/pull/1895)
- Implement flake8-commas by
[@&#8203;bluetech](https://togithub.com/bluetech) in
[https://github.com/charliermarsh/ruff/pull/1872](https://togithub.com/charliermarsh/ruff/pull/1872)
- refactor: Split CliSettings from Settings by
[@&#8203;not-my-profile](https://togithub.com/not-my-profile) in
[https://github.com/charliermarsh/ruff/pull/1891](https://togithub.com/charliermarsh/ruff/pull/1891)
- Skip noqa checker if no diagnostics are found by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1898](https://togithub.com/charliermarsh/ruff/pull/1898)
- Don't require docstrings for setters and deleters by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1899](https://togithub.com/charliermarsh/ruff/pull/1899)
- Buffer diagnostic writes to `stdout` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1900](https://togithub.com/charliermarsh/ruff/pull/1900)
- Lock `stdout` once when printing diagnostics by
[@&#8203;messense](https://togithub.com/messense) in
[https://github.com/charliermarsh/ruff/pull/1901](https://togithub.com/charliermarsh/ruff/pull/1901)
- Avoid triggering SIM117 for async with statements by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1903](https://togithub.com/charliermarsh/ruff/pull/1903)

#### New Contributors

- [@&#8203;TomFryers](https://togithub.com/TomFryers) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/1892](https://togithub.com/charliermarsh/ruff/pull/1892)

**Full Changelog**:
astral-sh/ruff@v0.0.222...v0.0.223

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDIuNyIsInVwZGF0ZWRJblZlciI6IjM0LjEwMi43In0=-->

Signed-off-by: Renovate Bot <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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