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

flynt checks breaking with package update to flynt-0.78 #472

Closed
bdperkin opened this issue Mar 24, 2023 · 4 comments · Fixed by #480
Closed

flynt checks breaking with package update to flynt-0.78 #472

bdperkin opened this issue Mar 24, 2023 · 4 comments · Fixed by #480
Assignees
Labels
bug Something isn't working

Comments

@bdperkin
Copy link

bdperkin commented Mar 24, 2023

Describe the bug
TypeError when executing darker --flynt which had been working with flynt-0.77

To Reproduce
Steps to reproduce the behavior:

  1. In a fresh virtualenv, pip3 install darker[flynt]
  2. Verify versions: pip3 freeze | grep -E "^(darker|flynt)" (currently: darker==1.7.0 and flynt==0.78)
  3. Run Darker with darker --flynt
  4. Get Traceback:
$ pip3 freeze | grep -E "^(darker|flynt)"
darker==1.7.0
flynt==0.78
$ darker --flynt
Traceback (most recent call last):
  File "${PWD}/venv/bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/__main__.py", line 630, in main_with_error_handling
    return main()
           ^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/__main__.py", line 586, in main
    for path, old, new in sorted(
                          ^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/__main__.py", line 107, in format_edited_parts
    ) = future.result()
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/concurrency.py", line 48, in submit
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/__main__.py", line 151, in _modify_and_reformat_single_file
    content_after_reformatting = _blacken_and_flynt_single_file(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/__main__.py", line 202, in _blacken_and_flynt_single_file
    fstringified = _maybe_flynt_single_file(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/__main__.py", line 264, in _maybe_flynt_single_file
    return apply_flynt(rev2_isorted, relpath_in_rev2, edited_linenums_differ)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/fstring.py", line 59, in apply_flynt
    return _call_flynt_fstringify(content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "${PWD}/venv/lib64/python3.11/site-packages/darker/fstring.py", line 70, in _call_flynt_fstringify
    result, _ = flynt_fstringify_code_by_line(content.string)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: fstringify_code_by_line() missing 1 required positional argument: 'state'

Expected behavior
No traceback and functioning as it did with flynt==0.78

Environment

  • LSB Version: :core-4.1-amd64:core-4.1-noarch
  • Distributor ID: Fedora
  • Description: Fedora release 37 (Thirty Seven)
  • Release: 37
  • Codename: ThirtySeven
  • Python version: Python 3.11.2
  • Git version: git version 2.39.2
  • Darker version: 1.7.0
  • Black version: black, 23.1.0 (compiled: yes); Python (CPython) 3.11.2
  • isort version: VERSION 5.10.1
  • flynt version: 0.78

Additional context
Running flynt standalone with this version is working.
Seems this may be the change that caused the issue: ikamensh/flynt@e66e7f6

@akaihola
Copy link
Owner

akaihola commented Mar 25, 2023

Thanks @bdperkin for the heads-up! This seems easy enough to fix.

I'll also consider adding similar similar automated "future" tests as we already have for upcoming Black versions (see #382 and #430).

Update: I added #473 to track this.

@jedie
Copy link
Contributor

jedie commented Mar 31, 2023

(currently: darker==1.7.0 and flynt==0.78)

I ran into the same problem with darker==1.7.1 and flynt==0.78 :(

jedie pushed a commit to boxine/bx_py_utils that referenced this issue Mar 31, 2023
Install flynt/isort/Pygments via darker "extras", to get always compatibility version combinations.
See: akaihola/darker#472
@jedie
Copy link
Contributor

jedie commented Mar 31, 2023

Oh it's my fault: The fix is to install flynt/isort/Pygments via darker "extras", to get always compatibility version combinations, isn't it?

@akaihola
Copy link
Owner

akaihola commented Apr 1, 2023

Hi @jedie; yes, Flynt 0.78 compatibility will be fixed soon (see #480), and meanwhile pip install 'darker[flynt]' will ensure a compatible version of Flynt is used.

jedie added a commit to jedie/cookiecutter_templates that referenced this issue Apr 2, 2023
Install flynt/isort/Pygments via darker "extras", to get always compatibility version combinations.
See: akaihola/darker#472
jedie pushed a commit to boxine/bx_django_utils that referenced this issue Apr 12, 2023
Install flynt, isort and pygments via darker `extras`, so we always get a working version
combination, see: akaihola/darker#472
jedie pushed a commit to boxine/bx_django_utils that referenced this issue Apr 12, 2023
Install flynt, isort and pygments via darker `extras`, so we always get a working version
combination, see: akaihola/darker#472
jedie pushed a commit to boxine/bx_django_utils that referenced this issue Apr 12, 2023
* Install flynt, isort and pygments via darker `extras`, so we always get a working version
combination, see: akaihola/darker#472
* Run tox parallelized.
* Fix tox config by install playwright browsers
jedie pushed a commit to boxine/bx_django_utils that referenced this issue Apr 12, 2023
* Split Django admin snapshots by new `name_suffix`
* Install flynt, isort and pygments via darker `extras`, so we always get a working version
combination, see: akaihola/darker#472
* Run tox parallelized.
* Fix tox config
* Use tox for `update-test-snapshot-files` to generate all snapshot files in all versions
* Move coverage generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

3 participants