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

How to stop <- from becomming < - #746

Closed RohanVashisht1234 closed 1 month ago

RohanVashisht1234 commented 1 month ago

Python like Code

<-

After formatting

< -

Command Line

$ autopep8 -i ./a.py

My Environment

is there a possible way to restrict <- becomming < -

RohanVashisht1234 commented 1 month ago

Basically, I just need some configuration that would restrict <- from becomming < - after formatting using the command line utility itself.

hhatto commented 1 month ago

It does not reproduce in my environment.

$ python -V
Python 3.11.7

$ autopep8 --version
autopep8 2.1.1 (pycodestyle: 2.11.1)

$ cat target.py
<-

$ autopep8 -d ./target.py  # Nothing is outputting any differences.
$ autopep8 -aaa -d ./target.py  # Nothing is outputting any differences.
RohanVashisht1234 commented 1 month ago

Sorry, please try this:

def main():
  do IO:
    * <- print("Hello, World!")
    return IO/Done((0))

ik, it isn't python code, but try this

RohanVashisht1234 commented 1 month ago

I think I managed to do this:

autopep8 -i --ignore E225,E226 --indent-size 2 "/Users/rohanvashisht/python/test/test.py"

I tried this, and this is working, please tell me if this is recommended.

RohanVashisht1234 commented 1 month ago

Is there a possible way to reserve only <- so that it doesn't become <-

hhatto commented 1 month ago

ik, it isn't python code, but try this

autopep8 does not support non-Python code. (Probably pycodestyle is not supported either.)