简体   繁体   中英

Pycharm is not reformatting code

I have heritage code in python with semicolon at the end of each line and mixed tab and spaces indentation.
PyCharm reports it at code inspection and suggest to reformat code. The problem is that when I click "Reformat Code" (which IDE recommends), Pycharm does nothing - code still contains semicolons and mixed indentation.
Why Code Reformat does not work?

Sample code:

for i in config.args.include:       
    if i.count(":") == 2:
        path, output, prefix = i.split(":");
    elif i.count(":") == 1:
        path, prefix = i.split(":");
        output = os.path.splitext(path)[0] + ".h";
    else:
        utils.fatal("Incorrect -a paramter tuple specification");

Please give the code example. ; at the end of line is not a python syntax. ; is ignored in workable code. But PyCharm cannot parse for example:

print "fdfdf"; for x in [1, 2, 3]: print("dsds")    print "d"

Ctrl+Alt+L:

print "fdfdf"; for x in [1, 2, 3]: print("dsds")
print "d"

But can parse:

print "fdfdf"   for x in [1, 2, 3]: print("dsds")    print "d"

to

print "fdfdf"
for x in [1, 2, 3]: print("dsds")
print "d"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM