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

ruff-rules-for-pyupgrade #436

Merged
merged 1 commit into from
Feb 14, 2025
Merged

Conversation

cclauss
Copy link
Collaborator

@cclauss cclauss commented Feb 10, 2025

% ruff check --target-version=py38 --select=UP --statistics

120	UP009	[*] utf8-encoding-declaration
 15	UP007	[*] non-pep604-annotation-union
 15	UP034	[*] extraneous-parentheses
  6	UP004	[*] useless-object-inheritance
  6	UP006	[*] non-pep585-annotation
  4	UP018	[*] native-literals
  2	UP012	[*] unnecessary-encode-utf8
  2	UP022	[*] replace-stdout-stderr
  1	UP015	[*] redundant-open-modes
  1	UP039	[*] unnecessary-class-parentheses

% ruff rule UP009

utf8-encoding-declaration (UP009)

Derived from the pyupgrade linter.

Fix is always available.

What it does

Checks for unnecessary UTF-8 encoding declarations.

Why is this bad?

PEP 3120 makes UTF-8 the default encoding, so a UTF-8 encoding
declaration is unnecessary.

Example

# -*- coding: utf-8 -*-
print("Hello, world!")

Use instead:

print("Hello, world!")

@cclauss cclauss force-pushed the ruff-rules-for-pyupgrade branch 3 times, most recently from ac4e27d to 7cc27fb Compare February 10, 2025 18:05
@boomanaiden154 boomanaiden154 self-requested a review February 10, 2025 18:50
Copy link
Collaborator

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Seems reasonable enough to me.

I can try and fix the license checking script for UP009.

@cclauss
Copy link
Collaborator Author

cclauss commented Feb 13, 2025

I will do UP009 in a separate pull request because it touches so many files.

@cclauss cclauss force-pushed the ruff-rules-for-pyupgrade branch 6 times, most recently from 547e5f6 to e80c4fd Compare February 14, 2025 07:27
@cclauss cclauss force-pushed the ruff-rules-for-pyupgrade branch from c59f7d4 to 50b21f7 Compare February 14, 2025 14:56
@cclauss cclauss merged commit 69284f6 into google:main Feb 14, 2025
13 checks passed
@cclauss cclauss deleted the ruff-rules-for-pyupgrade branch February 14, 2025 18:43
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