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.56k stars 290 forks source link

ValueError: invalid literal for int() with base 10: 'auto' #652

Closed bmzztt closed 1 year ago

bmzztt commented 1 year ago

I still see the issue described in https://github.com/hhatto/autopep8/issues/515 No autopep8 >=1.4.1 works for me. 1.4.0 works!

I use the default configuration and following is the output with -vvv:

enable config: section=flake8, key=max-line-length, value=120
enable config: section=flake8, key=ignore, value=D107, D400, W504, D204
enable config: section=flake8, key=exclude, value=
.git,
.venv,
__pycache__,
docs/source/conf.py,
build,
dist,
__init__.py
Traceback (most recent call last):
  File "C:\Users\mazzbru\work\autopep8\.venv\Scripts\autopep8-script.py", line 33, in <module>
    sys.exit(load_entry_point('autopep8==1.4.1', 'console_scripts', 'autopep8')())
  File "c:\users\mazzbru\work\autopep8\.venv\lib\site-packages\autopep8.py", line 4113, in main
    args = parse_args(argv[1:], apply_config=apply_config)
  File "c:\users\mazzbru\work\autopep8\.venv\lib\site-packages\autopep8.py", line 3597, in parse_args
    parser = read_config(args, parser)
  File "c:\users\mazzbru\work\autopep8\.venv\lib\site-packages\autopep8.py", line 3700, in read_config
    value = config.getint(section, k)
  File "C:\Program Files\Python39\lib\configparser.py", line 818, in getint
    return self._get_conv(section, option, int, raw=raw, vars=vars,
  File "C:\Program Files\Python39\lib\configparser.py", line 808, in _get_conv
    return self._get(section, conv, option, raw=raw, vars=vars,
  File "C:\Program Files\Python39\lib\configparser.py", line 803, in _get
    return conv(self.get(section, option, **kwargs))
ValueError: invalid literal for int() with base 10: 'auto'

Command Line

$ autopep8 -i <filename>

Your Environment

hhatto commented 1 year ago

Thanks for reporting.

reproduced when setup.cfg has the following case:

[flake8]
max-line-length = 120
ignore = D107, D400, W504, D204
exclude =
  .git,
  .venv,
  __pycache__,
  docs/source/conf.py,
  build,
  dist,
  __init__.py
max-complexity = 10
jobs = auto

This error occurs because jobs = auto value cannot be parsed on the autopep8 side. we fix it.

hhatto commented 1 year ago

@bmzztt This problem has been fixed in version 1.7.1. Please try the latest version.

bmzztt commented 1 year ago

It works now, thank you very much.