Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hhatto/autopep8
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.3.0
Choose a base ref
...
head repository: hhatto/autopep8
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.3.1
Choose a head ref

Commits on Jun 22, 2024

  1. Copy the full SHA
    6454d39 View commit details
  2. refactor

    hhatto committed Jun 22, 2024
    Copy the full SHA
    fae0bad View commit details
  3. codecov with 3.11 and 3.12

    hhatto committed Jun 22, 2024
    Copy the full SHA
    bba8b61 View commit details
  4. with flags

    hhatto committed Jun 22, 2024
    Copy the full SHA
    b5141d4 View commit details
  5. Merge pull request #755 from hhatto/cover-with-py312

    codecov with 3.11 and 3.12
    hhatto authored Jun 22, 2024
    Copy the full SHA
    a906e0e View commit details
  6. Copy the full SHA
    7a66033 View commit details
  7. Merge pull request #754 from hhatto/fix-issue-753

    skip e501 fixed method for f-string line without aggressive option
    hhatto authored Jun 22, 2024
    Copy the full SHA
    24cea97 View commit details

Commits on Jun 23, 2024

  1. Copy the full SHA
    decffbd View commit details
  2. remove future imports

    hhatto committed Jun 23, 2024
    Copy the full SHA
    089273c View commit details
  3. Copy the full SHA
    6a27d4d View commit details
  4. drop 3.7 in tox

    hhatto committed Jun 23, 2024
    Copy the full SHA
    d96bf49 View commit details
  5. fix: default value is int type

    hhatto committed Jun 23, 2024
    Copy the full SHA
    4c533b3 View commit details
  6. seperate SystemTests

    hhatto committed Jun 23, 2024
    Copy the full SHA
    a8126d5 View commit details
  7. Merge pull request #756 from hhatto/refactor-unit-test

    Refactor unit test
    hhatto authored Jun 23, 2024
    Copy the full SHA
    406f9ac View commit details
  8. remove coverall file

    hhatto committed Jun 23, 2024
    Copy the full SHA
    64763b7 View commit details
  9. remove

    hhatto committed Jun 23, 2024
    Copy the full SHA
    432d07e View commit details
  10. fix link, use codecov

    hhatto committed Jun 23, 2024
    Copy the full SHA
    be71168 View commit details
  11. add codecov setting file

    hhatto committed Jun 23, 2024
    Copy the full SHA
    87debd2 View commit details
  12. Merge pull request #757 from hhatto/remove-coveralls

    Remove coveralls
    hhatto authored Jun 23, 2024
    Copy the full SHA
    c55f3e0 View commit details
  13. Copy the full SHA
    5805a66 View commit details
  14. Copy the full SHA
    02592cc View commit details
  15. Merge pull request #758 from hhatto/fix-issue-713

    Fix argument parser errors are printed without a trailing newline
    hhatto authored Jun 23, 2024
    Copy the full SHA
    597b512 View commit details
  16. version 2.3.1

    hhatto committed Jun 23, 2024
    Copy the full SHA
    8530500 View commit details
Showing with 144 additions and 62 deletions.
  1. +5 −0 .codecov.yml
  2. +2 −1 .github/workflows/python-package.yml
  3. +0 −1 MANIFEST.in
  4. +2 −2 README.rst
  5. +49 −18 autopep8.py
  6. +0 −8 coveralls.bash
  7. +84 −30 test/test_autopep8.py
  8. +2 −2 tox.ini
5 changes: 5 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage:
status:
project:
default:
threshold: 1%
3 changes: 2 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -48,7 +48,8 @@ jobs:
python test/test_suite.py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == 3.11 && success()
if: (matrix.python-version == 3.11 || matrix.python-version == 3.12) && success()
with:
fail_ci_if_error: true
flags: ${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ recursive-exclude test/suite/out *.py
exclude .travis.yml
exclude CONTRIBUTING.rst
exclude Makefile
exclude coveralls.bash
exclude hooks
exclude hooks/pre-push
exclude install_hooks.bash
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -436,9 +436,9 @@ Links
* PyPI_
* GitHub_
* `Travis CI`_
* Coveralls_
* Codecov_

.. _PyPI: https://pypi.org/project/autopep8/
.. _GitHub: https://github.com/hhatto/autopep8
.. _`Travis CI`: https://travis-ci.org/hhatto/autopep8
.. _`Coveralls`: https://coveralls.io/r/hhatto/autopep8
.. _`Codecov`: https://app.codecov.io/gh/hhatto/autopep8
67 changes: 49 additions & 18 deletions autopep8.py
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ class documentation for more information.
import pycodestyle


__version__ = '2.3.0'
__version__ = '2.3.1'


CR = '\r'
@@ -1619,7 +1619,7 @@ def get_index_offset_contents(result, source):

def get_fixed_long_line(target, previous_line, original,
indent_word=' ', max_line_length=79,
aggressive=False, experimental=False, verbose=False):
aggressive=0, experimental=False, verbose=False):
"""Break up long line and return result.
Do this by generating multiple reformatted candidates and then
@@ -1896,7 +1896,7 @@ def _priority_key(pep8_result):


def shorten_line(tokens, source, indentation, indent_word, max_line_length,
aggressive=False, experimental=False, previous_line=''):
aggressive=0, experimental=False, previous_line=''):
"""Separate line at OPERATOR.
Multiple candidates will be yielded.
@@ -1934,7 +1934,7 @@ def shorten_line(tokens, source, indentation, indent_word, max_line_length,


def _shorten_line(tokens, source, indentation, indent_word,
aggressive=False, previous_line=''):
aggressive=0, previous_line=''):
"""Separate line at OPERATOR.
The input is expected to be free of newlines except for inside multiline
@@ -1943,11 +1943,20 @@ def _shorten_line(tokens, source, indentation, indent_word,
Multiple candidates will be yielded.
"""
in_string = False
for (token_type,
token_string,
start_offset,
end_offset) in token_offsets(tokens):

if IS_SUPPORT_TOKEN_FSTRING:
if token_type == tokenize.FSTRING_START:
in_string = True
elif token_type == tokenize.FSTRING_END:
in_string = False
if in_string:
continue

if (
token_type == tokenize.COMMENT and
not is_probably_part_of_multiline(previous_line) and
@@ -3846,13 +3855,23 @@ def _expand_codes(codes, ignore_codes):
return ret


def _parser_error_with_code(
parser: argparse.ArgumentParser, code: int, msg: str,
) -> None:
"""wrap parser.error with exit code"""
parser.print_usage(sys.stderr)
parser.exit(code, f"{msg}\n")


def parse_args(arguments, apply_config=False):
"""Parse command-line options."""
parser = create_parser()
args = parser.parse_args(arguments)

if not args.files and not args.list_fixes:
parser.exit(EXIT_CODE_ARGPARSE_ERROR, 'incorrect number of arguments')
_parser_error_with_code(
parser, EXIT_CODE_ARGPARSE_ERROR, 'incorrect number of arguments',
)

args.files = [decode_filename(name) for name in args.files]

@@ -3870,56 +3889,65 @@ def parse_args(arguments, apply_config=False):

if '-' in args.files:
if len(args.files) > 1:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'cannot mix stdin and regular files',
)

if args.diff:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--diff cannot be used with standard input',
)

if args.in_place:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--in-place cannot be used with standard input',
)

if args.recursive:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--recursive cannot be used with standard input',
)

if len(args.files) > 1 and not (args.in_place or args.diff):
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'autopep8 only takes one filename as argument '
'unless the "--in-place" or "--diff" args are used',
)

if args.recursive and not (args.in_place or args.diff):
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--recursive must be used with --in-place or --diff',
)

if args.in_place and args.diff:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--in-place and --diff are mutually exclusive',
)

if args.max_line_length <= 0:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--max-line-length must be greater than 0',
)

if args.indent_size <= 0:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--indent-size must be greater than 0',
)
@@ -3959,19 +3987,22 @@ def parse_args(arguments, apply_config=False):
args.jobs = multiprocessing.cpu_count()

if args.jobs > 1 and not (args.in_place or args.diff):
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'parallel jobs requires --in-place',
)

if args.line_range:
if args.line_range[0] <= 0:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'--range must be positive numbers',
)
if args.line_range[0] > args.line_range[1]:
parser.exit(
_parser_error_with_code(
parser,
EXIT_CODE_ARGPARSE_ERROR,
'First value of --range should be less than or equal '
'to the second',
@@ -4091,7 +4122,7 @@ def read_pyproject_toml(args, parser):
if config.get("tool", {}).get("autopep8") is None:
return None

config = config.get("tool").get("autopep8")
config = config.get("tool", {}).get("autopep8")

defaults = {}
option_list = {o.dest: o.type or type(o.default)
8 changes: 0 additions & 8 deletions coveralls.bash

This file was deleted.

Loading