python / python/mypy

EncodingWarning when running under PyPy

Open
#17,057 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

In this comment, I describe the warnings that I see when enabling mypy checks in PyPy.

To Reproduce

Grab jaraco/keyring@e9285df and run tox -e pypy (or tox -e pypy3 if pypy is aliased to Python 2). Note the tests run with PYTHONWARNDEFAULTENCODING=true.

Expected Behavior

There should be no warnings.

Actual Behavior

Warnings are emitted, three directly implicating mypy code and one implicated in configparser for mypy checks. I just ran the tests again and got even more warnings.

conftest.py::mypy
  /opt/homebrew/Cellar/pypy3.10/7.3.15/libexec/lib/pypy3.10/configparser.py:694: EncodingWarning: 'encoding' argument not specified.
    encoding = io.text_encoding(encoding)

conftest.py::mypy
  /Users/jaraco/code/jaraco/keyring/.tox/pypy/lib/pypy3.10/site-packages/mypy/modulefinder.py:851: EncodingWarning: 'encoding' argument not specified.
    with open(versions_path) as f:

conftest.py::mypy
  /Users/jaraco/code/jaraco/keyring/.tox/pypy/lib/pypy3.10/site-packages/mypy/metastore.py:108: EncodingWarning: 'encoding' argument not specified.
    with open(tmp_filename, "w") as f:

conftest.py::mypy
  /Users/jaraco/code/jaraco/keyring/.tox/pypy/lib/pypy3.10/site-packages/mypy/build.py:1187: EncodingWarning: 'encoding' argument not specified.
    with open(gitignore, "x") as f:

conftest.py::mypy
  /Users/jaraco/code/jaraco/keyring/.tox/pypy/lib/pypy3.10/site-packages/mypy/build.py:1201: EncodingWarning: 'encoding' argument not specified.
    with open(cachedir_tag, "x") as f:

conftest.py::mypy
  /Users/jaraco/code/jaraco/keyring/.tox/pypy/lib/pypy3.10/site-packages/mypy/build.py:3526: EncodingWarning: 'encoding' argument not specified.
    with open(fnam, "w") as f:

Your Environment

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with tox -e pypy and PYTHONWARNDEFAULTENCODING=true. Inspect the warning sites named in mypy/modulefinder.py, mypy/metastore.py, and mypy/build.py, while noting the separate configparser.py warning. Done means the relevant PyPy run completes without these EncodingWarning messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.