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

Fix encoding warnings with PEP 597 enabled #8893

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danyeaw
Copy link
Contributor

@danyeaw danyeaw commented Jan 21, 2024

Pull Request Check List

Resolves: #8892

  • Added tests for changed code.
  • Updated documentation for changed code.

This PR fixes Encoding Warnings with PEP 597 warnings enabled and enables the warnings in CI. There are also a few warnings with poetry-core and cleo, and I can submit PRs for those repos as well.

@radoering
Copy link
Member

pre-commit.ci autofix

Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

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

There are still some warnings we should address.

src/poetry/repositories/installed_repository.py Outdated Show resolved Hide resolved
@danyeaw
Copy link
Contributor Author

danyeaw commented Feb 11, 2024

We are down to 1 warning:

tests/console/commands/test_init.py::test_respect_prefer_active_on_init[True-1.1]
  /home/dan/Projects/poetry/tests/console/commands/test_init.py:1091: EncodingWarning: 'encoding' argument not specified.
    result: str = orig_check_output(cmd, *_, **__)

I'm not sure what to do about that one since it is a mocked out version of check_output.

@danyeaw
Copy link
Contributor Author

danyeaw commented Feb 11, 2024

Actually 1 more as well:

tests/vcs/git/test_system.py::TestSystemGit::test_clone_success
  /home/dan/Projects/poetry/src/poetry/vcs/git/system.py:43: EncodingWarning: 'encoding' argument not specified.
    subprocess.check_call(

I'm not sure how to apply encodings to a check_call.

@radoering
Copy link
Member

I'm not sure what to do about that one since it is a mocked out version of check_output.

The warning comes from calling the original method so I suppose at least one check_output() does not specify an encoding. Did you check that each check_output in the code base specifies an encoding? (Alternatively, you can catch the warning and re-emit it with stacklevel=2 to find the caller.)

I'm not sure how to apply encodings to a check_call.

Probably, the same as for the other methods. According to the docs it supports the same kwargs as Popen.

@danyeaw danyeaw force-pushed the fix-encoding-warnings branch 2 times, most recently from d750b6a to 4761b79 Compare May 17, 2024 00:39
@danyeaw
Copy link
Contributor Author

danyeaw commented May 17, 2024

Hi @radoering, I rebased this on top of the main branch. Unfortunately mypy gives a Unexpected keyword argument "encoding" for "check_call".

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.

Encoding Warnings with PEP 597 Warnings Enabled
3 participants