Skip to content

Treat integer Path.open argument as buffering - #157

Open
binggao1230 wants to merge 1 commit into
jaraco:mainfrom
binggao1230:fix-128-open-buffering-argument
Open

Treat integer Path.open argument as buffering#157
binggao1230 wants to merge 1 commit into
jaraco:mainfrom
binggao1230:fix-128-open-buffering-argument

Conversation

@binggao1230

Copy link
Copy Markdown

Fixes #128

Summary

  • update Path.open() so an integer second positional argument is treated as buffering instead of encoding
  • preserve the existing compatibility path where a non-integer second positional argument is still treated as an encoding
  • add a regression test for open("r", 1, encoding="utf-8")

Tests

  • Red before the fix: PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_path.py::TestPath::test_open -q failed with _extract_text_encoding() got multiple values for argument 'encoding'\n- PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_path.py::TestPath::test_open -q\n- PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest tests/test_path.py::TestPath::test_open_encoding_utf16 tests/test_path.py::TestPath::test_open_encoding_errors tests/test_path.py::TestPath::test_open_binary_invalid_args tests/test_path.py::TestPath::test_read -q\n- PYTHONPATH=. uv run --python 3.11 --with '.[test]' pytest -q\n- PYTHONPATH=. uv run --python 3.11 --with '.[test,check]' pytest --ruff -q\n- PYTHONPATH=. uv run --python 3.11 --with mypy mypy zipp\n- git diff --check\n\nI also ran PYTHONPATH=. uv run --python 3.11 --with '.[test,type]' pytest --mypy -q; it currently reports existing test-suite typing issues while pyproject.toml has the mypy pytest enabler disabled.\n\nAI assistance was used under my direction.

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.

Path.open() signature differs from pathlib, open() builtin

1 participant