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

Remove duplication around is_trivia functions #11956

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Conversation

dhruvmanila
Copy link
Member

Summary

This PR removes the duplication around is_trivia functions.

There are two of them in the codebase:

  1. In pycodestyle, it's for newline, indent, dedent, non-logical newline and comment
  2. In the parser, it's for non-logical newline and comment

The TokenKind::is_trivia method used (1) but that's not correct in that context. So, this PR introduces a new is_non_logical_token helper method for the pycodestyle crate and updates the TokenKind::is_trivia implementation with (2).

This also means we can remove Token::is_trivia method and the standalone token_source::is_trivia function and use the one on TokenKind.

Test Plan

cargo insta test

@dhruvmanila dhruvmanila added the internal An internal refactor or improvement label Jun 21, 2024
Copy link
Contributor

github-actions bot commented Jun 21, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+1 -0 violations, +0 -0 fixes in 1 projects; 49 projects unchanged)

PlasmaPy/PlasmaPy (+1 -0 violations, +0 -0 fixes)

+ src/plasmapy/diagnostics/langmuir.py:1396:23: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
NPY201 1 1 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+1 -0 violations, +0 -0 fixes in 1 projects; 49 projects unchanged)

PlasmaPy/PlasmaPy (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ src/plasmapy/diagnostics/langmuir.py:1396:23: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
NPY201 1 1 0 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@dhruvmanila dhruvmanila enabled auto-merge (squash) June 21, 2024 09:59
@dhruvmanila dhruvmanila merged commit 4667d86 into main Jun 21, 2024
16 of 17 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/trivia branch June 21, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants