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 python linter inconsistent behaviour with quotes #1112

Merged
merged 13 commits into from
Apr 17, 2024

Commits on Apr 15, 2024

  1. This has been a headache for a long time, and we had All-Hands-AI#1071

    …and All-Hands-AI#1100 with the hope to fix the inconsistent behaviour across linters and environments. However, we recently found out that double-quote-string-fixer plugin in pre-commit-hook has inconsistent behaviour on python 3.11 and 3.12. See discussion here. This is sad because while this plugin enforces single quote behaviour with 3.11, it doesn't always enforce so with 3.12. Specifically, with fstr syntax, this plugin allows both single quotes and double quotes with python 3.12.
    
    The problem is, some developers have black linter installed/integrated with their IDE, which is probably the most popular linter in python world (ranked by GitHub stars). This linter insists on always using double quotes. Now we have black and double-quote-string-fixer fight each other (iff the developer uses python 3.12) for some quotes (fstr syntax).
    
    After a lot of research, I couldn't find a way to enforce single quote behaviour without introducing a new dependency, flake8, together with a plugin for it to enforce quotes' behavior. I believe it's better off introducing the more popular black if we have to introduce a new linter. Since black and autopep8 sometimes fight each other, and they mostly overlap, I further remove autopep8.
    
    The unfortunate consequence of this PR is that I had to revert all single quotes back to double quotes. This might cause some inconvenience to existing PRs as they have to resolve conflicts, but I believe the headache will be gone soon. That being said, I am open to abandon this PR if anyone has a better idea to solve the headache.
    li-boxuan committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    cd5160e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    59bb657 View commit details
    Browse the repository at this point in the history
  3. Remove black

    li-boxuan committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    4087576 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    be665d5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b462854 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    419817b View commit details
    Browse the repository at this point in the history
  7. Fix quotes in config.py

    li-boxuan committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    2fd3371 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e7fedcc View commit details
    Browse the repository at this point in the history

Commits on Apr 16, 2024

  1. Configuration menu
    Copy the full SHA
    18c0954 View commit details
    Browse the repository at this point in the history
  2. Add back autopep8

    li-boxuan committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    e67efea View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    90db5d5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    626c8fd View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2024

  1. Configuration menu
    Copy the full SHA
    555a1d5 View commit details
    Browse the repository at this point in the history