zxcalc / pyzx

Python library for quantum circuit rewriting and optimisation using the ZX-calculus
Apache License 2.0
376 stars 114 forks source link

enforce PEP8 style with a tool such as pylint or autopep8 #122

Open dlyongemallo opened 1 year ago

dlyongemallo commented 1 year ago

Is there any reason not to enforce PEP8 (or any style, as long as it's consistent) on the code? It would make using certain development tasks, such as searching with something using regular expressions, somewhat easier.

dlyongemallo commented 1 year ago

(Would anyone seriously object if I started sending PRs to better align the code with PEP8 recommendations?)

jvdwetering commented 1 year ago

I'm a little against touching code that doesn't need to be touched, but not very strongly. If you want to put in the time to make it follow the convention, then go ahead. Although I do think that the restriction to 80 character long lines is too strict. On the other hand, if a line is that long that might be a sign that the code needs to be refactored to just not be that long.

dlyongemallo commented 1 year ago

Just out of curiosity, what development environment (OS, IDE, etc.) do the main contributors to this codebase (and, incidentally, zxlive) use? I'm mainly using PyCharm in Linux, but I also have access to Windows and VS Code. With modern IDEs there are a number of nice features like detecting common errors and suggested refactorings which implicitly depend on PEP8 style (e.g., because they use regular expression matching).

A unified style also makes code easier to read, e.g., if not b in list_of_bools can be easily misunderstood (the recommended style is if b not in list_of_bools).

jvdwetering commented 1 year ago

I don't know about the other contributors, but I wrote most of this code in Sublime, although I have now semi-switched to Visual Studio.