1

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");
7
  • Have you tried to ident the code first? Ctrl + alt + I is the shortcut for windows Commented Feb 29, 2016 at 13:44
  • 2
    What do you expect to get as an answer here? You own the code, which doesn't work. Why don't you just put in some effort to create the minimal example of code, which breaks the "Reformat Code" feature (if it really does) and report it to PyCharm issue tracker? Commented Feb 29, 2016 at 13:47
  • My code works, but PyCharm sees PEP8 coding style violation. Commented Feb 29, 2016 at 13:58
  • Indenting code does not removing trailing semicolons. Commented Feb 29, 2016 at 13:58
  • Okey, you found that PyCharm's inspection reports about "Trailing semicolon in the statement" and suggests to reformat the file. You do that and it appears that semicolon is not getting removed. Looks like a bug. What do you do when you suspect a bug? You go to the project's issue tracker search for similar issues already reported. If there is no such issues, you create minimal example to reproduce a problem, describe expected behaviour and submit a ticket. So what is the answer you're looking for here? Commented Feb 29, 2016 at 14:09

1 Answer 1

1

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.