Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

module 'pycodestyle' has no attribute 'missing_whitespace_around_operator' #689

Closed
adrianwix opened this issue Jul 29, 2023 · 11 comments · Fixed by #699
Closed

module 'pycodestyle' has no attribute 'missing_whitespace_around_operator' #689

adrianwix opened this issue Jul 29, 2023 · 11 comments · Fixed by #699

Comments

@adrianwix
Copy link


Python Code

image

Command Line and Configuration

.pep8, setup.cfg, ...

Whatever comes as default after installing autopep8 for the first time

Command Line

$ autopep8 -a -a --in-place --recursive --exclude postgres,pgadmin,demo_data . 

Your Environment

  • Python version: 3.10
  • pycodestyle = ">=2.10.0"
  • autopep8 version: *
  • Platform: macOSX
  • Running in pipenv
@adrianwix
Copy link
Author

I can't find a missing_whitespace_around_operator anywhere inside https://github.com/PyCQA/pycodestyle

@justindarcy
Copy link

I am seeing this issue as well
image

@TylerJang27
Copy link

Running into this as well. I think https://pypi.org/project/pycodestyle/#history released a breaking change in 2.11.0 that is hitting this. As a temporary fix I'm able to pin pycodestyle to 2.10.0, but ideally autopep8 would be able to handle this out of the box now.

pbrisbin added a commit to restyled-io/restylers that referenced this issue Aug 1, 2023
hhatto/autopep8#689

With latest pycodestyle (2.11), we get the following error:

    AttributeError: module 'pycodestyle' has no attribute 'missing_whitespace_around_operator'. Did you mean: 'whitespace_around_operator'?

autopep8 will need an update to match this. Until then, we have to stay
back on 2.10
@MiltiadisKoutsokeras
Copy link

I can confirm that problem in our code checking also. We use autopep8==2.0.2 and the stack trace is the following:

Traceback (most recent call last):
  File "<Project path here>/.venv/bin/autopep8", line 8, in <module>
    sys.exit(main())
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 4528, in main
    results = fix_multiple_files(args.files, args, sys.stdout)
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 4423, in fix_multiple_files
    ret = _fix_file((name, options, output))
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 4393, in _fix_file
    return fix_file(*parameters)
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 3589, in fix_file
    fixed_source = fix_lines(fixed_source, options, filename=filename)
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 3569, in fix_lines
    fixed_source = fix.fix()
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 613, in fix
    self._fix_source(filter_results(source=''.join(self.source),
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 557, in _fix_source
    modified_lines = fix(result)
  File "<Project path here>/.venv/lib/python3.9/site-packages/autopep8.py", line 761, in fix_e225
    pycodestyle.missing_whitespace_around_operator(fixed, ts))
AttributeError: module 'pycodestyle' has no attribute 'missing_whitespace_around_operator'

bcl added a commit to bcl/osbuild that referenced this issue Aug 4, 2023
They changed their API in 2.11.0 and broke autopep8
See:
hhatto/autopep8#689
and
hhatto/autopep8#696
bcl added a commit to bcl/osbuild that referenced this issue Aug 7, 2023
They changed their API in 2.11.0 and broke autopep8
See:
hhatto/autopep8#689
and
hhatto/autopep8#696
supakeen pushed a commit to bcl/osbuild that referenced this issue Aug 8, 2023
They changed their API in 2.11.0 and broke autopep8
See:
hhatto/autopep8#689
and
hhatto/autopep8#696
bcl added a commit to bcl/pykickstart that referenced this issue Aug 8, 2023
Add it to tox.ini and pin pycodestyle to 2.10.0 until it has been
updated to fix:
hhatto/autopep8#689 and
hhatto/autopep8#696

Add python-3.12.0-rc.1 to the github workflow, and updated the Ubuntu
runner to version 22.04
bcl added a commit to bcl/pykickstart that referenced this issue Aug 8, 2023
Add it to tox.ini and pin pycodestyle to 2.10.0 until it has been
updated to fix:
hhatto/autopep8#689 and
hhatto/autopep8#696

Add python-3.12.0-rc.1 to the github workflow

Do not switch to Ubuntu 22.04, it does not have python3.6 available and
we still need to test with it.
bcl added a commit to bcl/pykickstart that referenced this issue Aug 8, 2023
Add it to tox.ini and pin pycodestyle to 2.10.0 until it has been
updated to fix:
hhatto/autopep8#689 and
hhatto/autopep8#696

Add python-3.12.0-rc.1 to the github workflow

Do not switch to Ubuntu 22.04, it does not have python3.6 available and
we still need to test with it.
bcl added a commit to bcl/osbuild that referenced this issue Aug 9, 2023
They changed their API in 2.11.0 and broke autopep8
See:
hhatto/autopep8#689
and
hhatto/autopep8#696
supakeen pushed a commit to osbuild/osbuild that referenced this issue Aug 10, 2023
They changed their API in 2.11.0 and broke autopep8
See:
hhatto/autopep8#689
and
hhatto/autopep8#696
sk1p added a commit to sk1p/LiberTEM that referenced this issue Aug 10, 2023
sk1p added a commit to LiberTEM/LiberTEM that referenced this issue Aug 10, 2023
@shaperilio
Copy link

There are several pull requests for this; #699, #696, #691, #690 are all the same. I suggest someone look into this comment and push their PR forward with a solution.

@keriksson-rosenqvist-oqc
Copy link
Contributor

This is a possible solution that allows pycodestyle >= 2.11.0.
#696

@ststefa
Copy link

ststefa commented Oct 21, 2023

For the records, I had the same problem with pycodestyle 2.10.0. Just now, I tried it with 2.11.1 and it seems to be solved.

@folkien
Copy link

folkien commented Nov 13, 2023

Is solution to this error avaiable now or we have to wait?

Errors still remains on my setup (python 3.11) :
pycodestyle==2.11.1
autopep8==2.0.4

@hhatto
Copy link
Owner

hhatto commented Nov 13, 2023

This problem is solved in https://github.com/hhatto/autopep8/pull/699/files.
This change has also been released in autopep8 v2.0.4.

Please add a new issue if you have problems. Please include a code example of when the problem occurs.

@juanreyes00
Copy link

I got this problem with my pre-commit configuration, the solution was update the hook to the last version.

pycodestyle==2.11.1
autopep8==2.0.4
Python 3.11

  - repo: https://github.com/pre-commit/mirrors-autopep8
    rev: v2.0.4
    hooks:
      - id: autopep8

@essamgouda97
Copy link

I got this problem with my pre-commit configuration, the solution was update the hook to the last version.

pycodestyle==2.11.1 autopep8==2.0.4 Python 3.11

  - repo: https://github.com/pre-commit/mirrors-autopep8
    rev: v2.0.4
    hooks:
      - id: autopep8

That worked, thanks !

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.