Skip to content

Commit

Permalink
Merge branch 'master' into lalufu/feature-percent-s-alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ikamensh authored Aug 21, 2024
2 parents 4acbc3d + d280d03 commit b4e19c6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --format=github .
- run: ruff check -- --format=github .
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ env:
FORCE_COLOR: 1

jobs:
build:
test:
runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
Expand Down
16 changes: 15 additions & 1 deletion test/integration/test_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
""" Test str processors on actual file contents """
"""Test str processors on actual file contents"""

import sys
from functools import partial
from test.integration.utils import samples, try_on_file

Expand All @@ -10,6 +12,12 @@

@pytest.mark.parametrize("filename", samples)
def test_fstringify(filename, state):
# this skips "string_in_string.py" for python >=3.12.
# the behavior on these python versions differs. In fact, 3.12 behavior is preferable.
# When only supported versions are 3.12 and up, expected output should be modified.
if filename == "string_in_string.py" and sys.version_info > (3, 11):
return

out, expected = try_on_file(
filename,
partial(fstringify_code_by_line, state=state),
Expand All @@ -19,6 +27,12 @@ def test_fstringify(filename, state):

@pytest.mark.parametrize("filename", samples)
def test_fstringify_single_line(filename):
# this skips "string_in_string.py" for python >=3.12.
# the behavior on these python versions differs. In fact, 3.12 behavior is preferable.
# When only supported versions are 3.12 and up, expected output should be modified.
if filename == "string_in_string.py" and sys.version_info > (3, 11):
return

state = State(multiline=False)
out, expected = try_on_file(
filename,
Expand Down
11 changes: 9 additions & 2 deletions test/test_edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,17 @@ def test_mixed_quote_types(state: State):


def test_mixed_quote_types_unsafe(state: State):
"""Test that a multiline, mixed-quotes expression is transformed."""
"""Transforming an expression with quotes in it is more tricky.
Currently its transformed when running on python >= 3.12, otherwise not."""

expected = '''f"one \\"{'\\"'.join(one)}\\" , two {two}"'''

out, count = code_editor.fstringify_code_by_line(s_in_mixed_quotes_unsafe, state)
assert out == s_in_mixed_quotes_unsafe
if sys.version_info < (3, 12):
assert out == s_in_mixed_quotes_unsafe
else:
assert out == expected


def test_super_call(state: State):
Expand Down

0 comments on commit b4e19c6

Please sign in to comment.