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

Update code style #31

Merged
merged 17 commits into from
Jan 9, 2024
Merged

Update code style #31

merged 17 commits into from
Jan 9, 2024

Commits on Jan 8, 2024

  1. Remove undesirable pre-commit checks

    We use print statements for console output, so shouldn't run flake8-print.
    
    We run black as part of pre-commit already, so don't need to run flake8-black.
    
    We can safely ignore the following flake8 checks:
    - S105: We don't use any passwords, so don't need to check for them.
    - E203: flake8 and black disagree on how to format [x : y]
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    bfe79c0 View commit details
    Browse the repository at this point in the history
  2. Add compatibility options to pre-commit hooks

    black and isort both require explicit line lengths for compatibility with
    flake8's default length of 79 characters.
    
    isort additionally needs to be told to use black-compatible formatting.
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    fe65833 View commit details
    Browse the repository at this point in the history
  3. Re-order pre-commit checks to minimize passes

    With the original order, it was possible for files to fail the pre-commit
    multiple times. For example, running black may introduce a new multi-line
    statement that add-trailing-comma couldn't adjust (because it ran first).
    
    The new order tries to group hooks to update:
    1) Formatting-independent syntax
    2) Statement order
    3) Formatting
    4) Formatting-dependent syntax
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    0edd372 View commit details
    Browse the repository at this point in the history
  4. Run new pre-commit hooks on all files

    This commit enforces the new formatting, but does nothing to address any of the
    errors raised by the new linter.
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    ccebb31 View commit details
    Browse the repository at this point in the history
  5. Remove imported but unused modules

    F401
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    26b7b79 View commit details
    Browse the repository at this point in the history
  6. Rename variables with ambiguous names

    E741
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    55b488c View commit details
    Browse the repository at this point in the history
  7. Fix f-string with missing placeholders

    F541
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    cf9544e View commit details
    Browse the repository at this point in the history
  8. Fix reference to undefined name "ParserError"

    F821
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    adbf6b2 View commit details
    Browse the repository at this point in the history
  9. Move module level imports to top of file

    E402
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    d3a1768 View commit details
    Browse the repository at this point in the history
  10. Use isinstance instead of comparing types

    E721
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    2631149 View commit details
    Browse the repository at this point in the history
  11. Replace '%' operator with f-strings

    FS001
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    bacdf2d View commit details
    Browse the repository at this point in the history
  12. Replace usage of '.format' with f-strings

    FS002
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    6765eaa View commit details
    Browse the repository at this point in the history
  13. Manually wrap some lines to 79 characters

    E501
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    5300ba5 View commit details
    Browse the repository at this point in the history
  14. Remove comments used to disable old hooks

    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    df852a5 View commit details
    Browse the repository at this point in the history
  15. Bump copyright to 2024

    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    2e3c66f View commit details
    Browse the repository at this point in the history
  16. Ignore F401 in __init__.py files

    F401 is 'Module imported but unused'. Ignoring F401 for all __init__.py files
    seems like a cleaner solution than introducing unnecessary references to the
    modules (e.g. via __all__ or similar).
    
    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    ca465f2 View commit details
    Browse the repository at this point in the history
  17. Use matplotlib functions consistently

    Signed-off-by: John Pennycook <[email protected]>
    Pennycook committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    3d55e51 View commit details
    Browse the repository at this point in the history