Skip to content

Conversation

@cclauss
Copy link
Contributor

@cclauss cclauss commented Dec 19, 2025

https://github.com/asottile/pyupgrade

% ruff check --select=UP --target-version=py38 --statistics # https://docs.astral.sh/ruff/rules/#pyupgrade-up

7	UP009	[*] utf8-encoding-declaration
7	UP025	[*] unicode-kind-prefix
7	UP031	[ ] printf-string-formatting
3	UP034	[*] extraneous-parentheses
2	UP004	[*] useless-object-inheritance
1	UP032	[*] f-string
Found 27 errors.
[*] 20 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

% 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!")

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.

1 participant

SYSTEM_READY >> ...MS