Skip to content

Commit

Permalink
Merge branch 'main' into format-pattern-match-or
Browse files Browse the repository at this point in the history
  • Loading branch information
LaBatata101 authored Aug 26, 2023
2 parents 67afda5 + eae59cf commit 25e5224
Show file tree
Hide file tree
Showing 63 changed files with 11,910 additions and 11,896 deletions.
136 changes: 0 additions & 136 deletions .github/workflows/benchmark.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,28 @@ jobs:
run: cat target/progress_projects_stats.txt > $GITHUB_STEP_SUMMARY
- name: "Remove checkouts from cache"
run: rm -r target/progress_projects

benchmarks:
runs-on: ubuntu-latest
steps:
- name: "Checkout Branch"
uses: actions/checkout@v3

- name: "Install Rust toolchain"
run: rustup show

- name: "Install codspeed"
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed

- uses: Swatinem/rust-cache@v2

- name: "Build benchmarks"
run: cargo codspeed build --features codspeed -p ruff_benchmark

- name: "Run benchmarks"
uses: CodSpeedHQ/action@v1
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
29 changes: 5 additions & 24 deletions .github/workflows/pr-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR Check Comment

on:
workflow_run:
workflows: [CI, Benchmark]
workflows: [CI]
types: [completed]
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -43,35 +43,16 @@ jobs:
path: pr/ecosystem
if_no_artifact_found: ignore

- uses: dawidd6/action-download-artifact@v2
name: "Download Benchmark Result"
id: download-benchmark-result
if: steps.pr-number.outputs.pr-number
with:
name: summary
workflow: benchmark.yaml
pr: ${{ steps.pr-number.outputs.pr-number }}
path: pr/benchmark
if_no_artifact_found: ignore

- name: Generate Comment
id: generate-comment
if: steps.download-ecosystem-result.outputs.found_artifact == 'true' || steps.download-benchmark-result.outputs.found_artifact == 'true'
if: steps.download-ecosystem-result.outputs.found_artifact == 'true'
run: |
echo 'comment<<EOF' >> $GITHUB_OUTPUT
echo '## PR Check Results' >> $GITHUB_OUTPUT
if [[ -f pr/ecosystem/ecosystem-result ]]
then
echo "### Ecosystem" >> $GITHUB_OUTPUT
cat pr/ecosystem/ecosystem-result >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
fi
if [[ -f pr/benchmark/summary.md ]]
then
cat pr/benchmark/summary.md >> $GITHUB_OUTPUT
fi
echo "### Ecosystem" >> $GITHUB_OUTPUT
cat pr/ecosystem/ecosystem-result >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
Expand Down
27 changes: 25 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_raise/RSE102.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ def error():

# OK
raise ctypes.WinError(1)


# RSE102
raise IndexError()from ZeroDivisionError

raise IndexError()\
from ZeroDivisionError

raise IndexError() from ZeroDivisionError

raise IndexError();
32 changes: 32 additions & 0 deletions crates/ruff/resources/test/fixtures/pyupgrade/UP007.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,35 @@ def f() -> None:
x = Union["str", "int"]
x: Union[str, int]
x: Union["str", "int"]


def f(x: Union[int : float]) -> None:
...


def f(x: Union[str, int : float]) -> None:
...


def f(x: Union[x := int]) -> None:
...


def f(x: Union[str, x := int]) -> None:
...


def f(x: Union[lambda: int]) -> None:
...


def f(x: Union[str, lambda: int]) -> None:
...


def f(x: Optional[int : float]) -> None:
...


def f(x: Optional[str, int : float]) -> None:
...
31 changes: 25 additions & 6 deletions crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use super::helpers::{is_pytest_parametrize, split_names};
/// ## Why is this bad?
/// The `argnames` argument of `pytest.mark.parametrize` takes a string or
/// a sequence of strings. For a single parameter, it's preferable to use a
/// string, and for multiple parameters, it's preferable to use the style
/// configured via the `flake8-pytest-style.parametrize-names-type` setting.
/// string. For multiple parameters, it's preferable to use the style
/// configured via the [`flake8-pytest-style.parametrize-names-type`] setting.
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -95,10 +95,28 @@ impl Violation for PytestParametrizeNamesWrongType {
///
/// ## Why is this bad?
/// The `argvalues` argument of `pytest.mark.parametrize` takes an iterator of
/// parameter values. For a single parameter, it's preferable to use a list,
/// and for multiple parameters, it's preferable to use a list of rows with
/// the type configured via the `flake8-pytest-style.parametrize-values-row-type`
/// setting.
/// parameter values, which can be provided as lists or tuples.
///
/// To aid in readability, it's recommended to use a consistent style for the
/// list of values rows, and, in the case of multiple parameters, for each row
/// of values.
///
/// The style for the list of values rows can be configured via the
/// the [`flake8-pytest-style.parametrize-values-type`] setting, while the
/// style for each row of values can be configured via the
/// the [`flake8-pytest-style.parametrize-values-row-type`] setting.
///
/// For example, [`flake8-pytest-style.parametrize-values-type`] will lead to
/// the following expectations:
///
/// - `tuple`: `@pytest.mark.parametrize("value", ("a", "b", "c"))`
/// - `list`: `@pytest.mark.parametrize("value", ["a", "b", "c"])`
///
/// Similarly, [`flake8-pytest-style.parametrize-values-row-type`] will lead to
/// the following expectations:
///
/// - `tuple`: `@pytest.mark.parametrize(("key", "value"), [("a", "b"), ("c", "d")])`
/// - `list`: `@pytest.mark.parametrize(("key", "value"), [["a", "b"], ["c", "d"]])`
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -151,6 +169,7 @@ impl Violation for PytestParametrizeNamesWrongType {
/// ```
///
/// ## Options
/// - `flake8-pytest-style.parametrize-values-type`
/// - `flake8-pytest-style.parametrize-values-row-type`
///
/// ## References
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,25 @@ pub(crate) fn unnecessary_paren_on_raise_exception(checker: &mut Checker, expr:

let mut diagnostic = Diagnostic::new(UnnecessaryParenOnRaiseException, arguments.range());
if checker.patch(diagnostic.kind.rule()) {
diagnostic.set_fix(Fix::automatic(Edit::range_deletion(arguments.range())));
// If the arguments are immediately followed by a `from`, insert whitespace to avoid
// a syntax error, as in:
// ```python
// raise IndexError()from ZeroDivisionError
// ```
if checker
.locator()
.after(arguments.end())
.chars()
.next()
.is_some_and(char::is_alphanumeric)
{
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
" ".to_string(),
arguments.range(),
)));
} else {
diagnostic.set_fix(Fix::automatic(Edit::range_deletion(arguments.range())));
}
}
checker.diagnostics.push(diagnostic);
}
Expand Down
Loading

0 comments on commit 25e5224

Please sign in to comment.