Skip to content
Merged

py311+ #3771

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/pre-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ runs:
using: composite
steps:
- uses: asottile/workflows/.github/actions/latest-git@v1.4.0
if: inputs.env == 'py310' && runner.os == 'Linux'
if: inputs.env == 'py311' && runner.os == 'Linux'
4 changes: 2 additions & 2 deletions .github/workflows/languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: install deps
run: python -mpip install -e . -r requirements-dev.txt
- name: vars
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: asottile/workflows/.github/actions/fast-checkout@v1.8.1
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'

- run: echo "$CONDA\Scripts" >> "$GITHUB_PATH"
shell: bash
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ concurrency:

jobs:
main-windows:
uses: asottile/workflows/.github/workflows/tox.yml@v1.8.1
uses: asottile/workflows/.github/workflows/tox.yml@v1.11.1
with:
env: '["py310"]'
env: '["py311"]'
os: windows-latest
main-linux:
uses: asottile/workflows/.github/workflows/tox.yml@v1.8.1
uses: asottile/workflows/.github/workflows/tox.yml@v1.11.1
with:
env: '["py310", "py311", "py312", "py313"]'
env: '["py311", "py312", "py313", "py314"]'
os: ubuntu-latest
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
hooks:
- id: reorder-python-imports
exclude: ^pre_commit/resources/
args: [--py310-plus, --add-import, 'from __future__ import annotations']
args: [--py311-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v4.0.0
hooks:
Expand All @@ -27,7 +27,7 @@ repos:
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py310-plus]
args: [--py311-plus]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install_requires =
nodeenv>=0.11.1
pyyaml>=5.1
virtualenv>=20.10.0
python_requires = >=3.10
python_requires = >=3.11

[options.packages.find]
exclude =
Expand Down
2 changes: 1 addition & 1 deletion testing/zipapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:jammy
FROM ubuntu:noble
RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion testing/zipapp/make
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _add_shim(dest: str) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
_exit_if_retv(
'podman', 'run', '--rm', '--volume', f'{tmpdir}:/out:rw', IMG,
'cp', '/venv/lib/python3.10/site-packages/distlib/t32.exe', '/out',
'cp', '/venv/lib/python3.12/site-packages/distlib/t32.exe', '/out',
)

with open(os.path.join(dest, 'python.exe'), 'wb') as f:
Expand Down
30 changes: 18 additions & 12 deletions tests/color_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,30 @@ def test_use_color_no_tty():


def test_use_color_tty_with_color_support():
with mock.patch.object(sys.stderr, 'isatty', return_value=True):
with mock.patch('pre_commit.color.terminal_supports_color', True):
with envcontext.envcontext((('TERM', envcontext.UNSET),)):
assert use_color('auto') is True
with (
mock.patch.object(sys.stderr, 'isatty', return_value=True),
mock.patch('pre_commit.color.terminal_supports_color', True),
envcontext.envcontext((('TERM', envcontext.UNSET),)),
):
assert use_color('auto') is True


def test_use_color_tty_without_color_support():
with mock.patch.object(sys.stderr, 'isatty', return_value=True):
with mock.patch('pre_commit.color.terminal_supports_color', False):
with envcontext.envcontext((('TERM', envcontext.UNSET),)):
assert use_color('auto') is False
with (
mock.patch.object(sys.stderr, 'isatty', return_value=True),
mock.patch('pre_commit.color.terminal_supports_color', False),
envcontext.envcontext((('TERM', envcontext.UNSET),)),
):
assert use_color('auto') is False


def test_use_color_dumb_term():
with mock.patch.object(sys.stderr, 'isatty', return_value=True):
with mock.patch('pre_commit.color.terminal_supports_color', True):
with envcontext.envcontext((('TERM', 'dumb'),)):
assert use_color('auto') is False
with (
mock.patch.object(sys.stderr, 'isatty', return_value=True),
mock.patch('pre_commit.color.terminal_supports_color', True),
envcontext.envcontext((('TERM', 'dumb'),)),
):
assert use_color('auto') is False


def test_use_color_raises_if_given_shenanigans():
Expand Down
26 changes: 15 additions & 11 deletions tests/commands/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,20 +1123,24 @@ def test_classifier_removes_dne():


def test_classifier_normalizes_filenames_on_windows_to_forward_slashes(tmpdir):
with tmpdir.as_cwd():
tmpdir.join('a/b/c').ensure()
with mock.patch.object(os, 'altsep', '/'):
with mock.patch.object(os, 'sep', '\\'):
classifier = Classifier.from_config((r'a\b\c',), '', '^$')
assert classifier.filenames == ['a/b/c']
tmpdir.join('a/b/c').ensure()
with (
tmpdir.as_cwd(),
mock.patch.object(os, 'altsep', '/'),
mock.patch.object(os, 'sep', '\\'),
):
classifier = Classifier.from_config((r'a\b\c',), '', '^$')
assert classifier.filenames == ['a/b/c']


def test_classifier_does_not_normalize_backslashes_non_windows(tmpdir):
with mock.patch.object(os.path, 'lexists', return_value=True):
with mock.patch.object(os, 'altsep', None):
with mock.patch.object(os, 'sep', '/'):
classifier = Classifier.from_config((r'a/b\c',), '', '^$')
assert classifier.filenames == [r'a/b\c']
with (
mock.patch.object(os.path, 'lexists', return_value=True),
mock.patch.object(os, 'altsep', None),
mock.patch.object(os, 'sep', '/'),
):
classifier = Classifier.from_config((r'a/b\c',), '', '^$')
assert classifier.filenames == [r'a/b\c']


def test_classifier_empty_types_or(tmpdir):
Expand Down
16 changes: 9 additions & 7 deletions tests/repository_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,16 @@ class MyKeyboardInterrupt(KeyboardInterrupt):
# To simulate a killed install, we'll make PythonEnv.run raise ^C
# and then to simulate a second ^C during cleanup, we'll make shutil.rmtree
# raise as well.
with pytest.raises(MyKeyboardInterrupt):
with mock.patch.object(
lang_base, 'setup_cmd', side_effect=MyKeyboardInterrupt,
):
with mock.patch.object(
with (
pytest.raises(MyKeyboardInterrupt),
mock.patch.object(
lang_base, 'setup_cmd', side_effect=MyKeyboardInterrupt,
),
mock.patch.object(
shutil, 'rmtree', side_effect=MyKeyboardInterrupt,
):
install_hook_envs(hooks, store)
),
):
install_hook_envs(hooks, store)

# Should have made an environment, however this environment is broken!
hook, = hooks
Expand Down
Loading