hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.54k stars 291 forks source link

Fix to use the function fix_file() separately with options parameter #721

Closed kulkarnisg closed 6 months ago

kulkarnisg commented 6 months ago

Resolved issue (AttributeError: 'dict' object has no attribute 'in_place' if tried ) for using fix_file() in python script with options as dictionary.

Can use autopep8.fix_file(python_file_name, options={'in_place': True, "aggressive": 2}, apply_config=True) now.

Details as per guidelines:

  1. Does not involve pycodestyle tool

  2. autopep8 --version autopep8 2.0.4

  3. pycodestyle --version 2.11.1

  4. python --version Python 3.11.4

  5. Not on Unix

  6. Error while using below code directly using imports autopep8.fix_file(python_file_name, options={'in_place': True, "aggressive": 2}, apply_config=True) Getting: AttributeError: 'dict' object has no attribute 'in_place'

  7. Not using autopep8 command

  8. The implementation should not raise an error

  9. Using the latest release

codecov-commenter commented 6 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (af7399d) 97.83% compared to head (0e21fe4) 97.79%.

Files Patch % Lines
autopep8.py 50.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #721 +/- ## ========================================== - Coverage 97.83% 97.79% -0.04% ========================================== Files 1 1 Lines 2402 2404 +2 ========================================== + Hits 2350 2351 +1 - Misses 52 53 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.