Skip to content

encoding error with Windows OS and UTF-8 chars in .pre-commit-config.yml #62

Open
@david-mcdowell-ilw

Description

@david-mcdowell-ilw

System:

  • Windows 11
  • Python 3.12
$ uv run pre-commit --version
pre-commit 4.2.0 (pre-commit-uv=4.1.4, uv=0.7.9)

Issue

I tried adding this pre-commit hook to my .pre-commit-config.yml, but when I attempt to run it, it errors on what I assume is one of the emoji characters used in the name option of other hooks defined in the config file.

Image

I suspect this is related to the python open() function defaulting to a cp1252 encoding for Windows OS if the encoding is not specified in the function call (line 50 of sync-pre-commit-deps/sync_pre_commit_deps.py):

    with open(filename) as f:
        loaded = yaml.load(f)

Could the encoding on read default to utf-8? For example:

    with open(filename, encoding="utf-8") as f:
        loaded = yaml.load(f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions