forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Merge master 26-03-2024 #34
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
## Summary References astral-sh#970. Implements [`dict-iter-missing-items`](https://pylint.readthedocs.io/en/latest/user_guide/messages/error/dict-iter-missing-items.html). Took the tests from "upstream" [here](https://github.com/DanielNoord/pylint/blob/main/tests/functional/d/dict_iter_missing_items.py). ~I wasn't able to implement code for one false positive, but it is pretty estoric: pylint-dev/pylint#3283. I would personally argue that adding this check as preview rule without supporting this specific use case is fine. I did add a "test" for it.~ This was implemented. ## Test Plan Followed the Contributing guide to create tests, hopefully I didn't miss any. Also ran CI on my own fork and seemed to be all okay 😄 ~Edit: the ecosystem check seems a bit all over the place? 😅~ All good. --------- Co-authored-by: Dhruv Manilawala <[email protected]> Co-authored-by: Charlie Marsh <[email protected]>
…e support (astral-sh#10055) ## Summary Closes astral-sh#10031 - Detect commented out `case` statements. Playground repro: https://play.ruff.rs/5a305aa9-6e5c-4fa4-999a-8fc427ab9a23 - Add more support for one-line commented out code. ## Test Plan Unit tested and tested with ```sh cargo run -p ruff -- check crates/ruff_linter/resources/test/fixtures/eradicate/ERA001.py --no-cache --preview --select ERA001 ``` TODO: - [x] `cargo insta test`
…-sh#10057) Co-authored-by: Charlie Marsh <[email protected]>
…02`) (astral-sh#10066) ## Summary Allows, e.g.: ```python import os os.environ["WORLD_SIZE"] = "1" os.putenv("CUDA_VISIBLE_DEVICES", "4") import torch ``` For now, this is only allowed in preview. Closes astral-sh#10059
## Summary Update PLR1714 to ignore `sys.platform` and `sys.version` checks. I'm not sure if these checks or if we need to add more. Please advise. Fixes astral-sh#10017 ## Test Plan Added a new test case and ran `cargo nextest run`
… to "Who is using Ruff" section (astral-sh#10075)
Co-authored-by: Micha Reiser <[email protected]>
…h#10091) ## Summary The original implementation of this applied the runtime-required context to definitions _within_ the function, but not the signature itself. (We had test coverage; the snapshot was just correctly showing the wrong outcome.) Closes astral-sh#10089.
…astral-sh#10118) ## Summary It is a convention to use the `_()` alias for `gettext()`. We want to avoid statement expressions and assignments related to aliases of the gettext API. See https://docs.python.org/3/library/gettext.html for details. When one uses `_() to mark a string for translation, the tools look for these markers and replace the original string with its translated counterpart. If the string contains variable placeholders or formatting, it can complicate the translation process, lead to errors or incorrect translations. ## Test Plan * Test file `RUF027_1.py` was extended such that the test reproduces the false-positive Closes astral-sh#10023. --------- Co-authored-by: Charlie Marsh <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
## Summary PEP 420 says [nested namespace packages](https://peps.python.org/pep-0420/#nested-namespace-packages) are allowed, i.e. marking a directory as a namespace package marks all subdirectories in the subtree as namespace packages. `is_package` is modified to use `Path::starts_with` and the order of checks is reversed to do in-memory checks first before hitting the disk. ## Test Plan Added unit tests. Previously all tests were run with `namespace_packages == &[]`. Verified that one of the tests was failing before changing the implementation. ## Future Improvements The `is_package_with_cache` can probably be rewritten to avoid repeated calls to `Path::starts_with`, by caching all directories up to the `namespace_root`: ```ruff let namespace_root = namespace_packages .iter() .filter(|namespace_package| path.starts_with(namespace_package)) .min(); ```
## Summary Continuing with astral-sh#7595, this PR moves the `Q004` rule to the AST checker. ## Test Plan - [x] Existing test cases should pass - [x] No ecosystem updates
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…cell (astral-sh#10291) ## Summary Closes astral-sh#10228 The PR makes the blank lines rules keep track of the cell status when running on a notebook, and makes the rules not trigger when the line is the first of the cell. ## Test Plan The example given in astral-sh#10228 is added as a fixture, along with a few tests from the main blank lines fixtures.
…sh`) (astral-sh#10566) ## Summary Fixed false-positive on the rule `PLW1641`, where the explicit assignment on the `__hash__` method is not counted as an definition of `__hash__`. (Discussed in astral-sh#10557). Also, added one new testcase. ## Test Plan Checked on `cargo test` in `eq_without_hash.py`. Before the change, for the assignment into `__hash__`, only `__hash__ = None` was counted as an explicit definition of `__hash__` method. Probably any assignment into `__hash__` property could be counted as an explicit definition of hash, so I removed `value.is_none_literal_expr()` check.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
) ## Summary This is not the holistic solution but just to fix that issue. fixes: astral-sh#10546 ## Test Plan Add a regression test for it and check the snapshots.
…al-sh#10587) ## Summary This is just a nitpicky improvement, but I thought it'd be a good opportunity to look at the ruff source. > The rules list in the documentation is generated using the registry order. Currently, flake8-logging is separated from the rest of the flake8 plugins. This patch puts it next to them. https://docs.astral.sh/ruff/rules/ If it makes sense, we could alternatively just sort the linters in https://github.com/astral-sh/ruff/blob/main/crates/ruff_dev/src/generate_rules_table.rs. Signed-off-by: Filipe Laíns <[email protected]>
Judging from the other lists in this same file, it looks like a blank line is required to separate the previous paragraph from the first list item. Otherwise the list is considered part of the paragraph: - https://docs.astral.sh/ruff/settings/#lint_flake8-copyright_notice-rgx <img width="400" alt="image" src="https://github.com/astral-sh/ruff/assets/282592/663fa5b4-f787-4fcd-bdd6-0b891d7ad72b"> - https://docs.astral.sh/ruff/settings/#format_quote-style <img width="400" alt="image" src="https://github.com/astral-sh/ruff/assets/282592/809735eb-c546-4348-9311-877441bae84e"> After this change hopefully those will be rendered as proper bullet lists.
…matches `C416` (astral-sh#10596) ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Similar to astral-sh#10419, there was a case where there is a collision of C401 and C416 (as discussed in astral-sh#10101). Fixed this by implementing short-circuit for the comprehension of the form `{x for x in foo}`. ## Test Plan <!-- How was it tested? --> Extended `C401.py` with the case where `set` is not builtin function, and divided the case where the short-circuit should occur. Removed the last testcase of `print(f"{ {set(a for a in 'abc')} }")` test as this is invalid as a python code, but should I keep this?
…stral-sh#10565) ## Summary This PR adds an overview and roadmap to the `README.md` for the `ruff_server` crate along with a rudimentary `CONTRIBUTING.md` that explains some of the technical decisions behind the project and basic information about local testing.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Test Plan