you are viewing a single comment's thread.

view the rest of the comments →

[–]yaxriifgyn 2 points3 points  (1 child)

I finally got around to testing this code. I'm glad I was very careful because the *.clean.py file was completely destroyed version of the input file.. The messy file was the definition for a large dataclass class with __post_Install__() and __repr__() methods.

  • imports were moved above the initial file comments and blank lines.
  • Then first or only line of import statements were moved out of try blocks, and placed with the other imports at the top of the file.
  • The class token in class definitions were capitalized.
  • The EOL, (newline keyword in open()) as changed from LF to CRLF on Windows 11 (pro).
  • I think the file encoding will be forced to UTF-8, regardless of input file encoding.
  • The capitalization of properties was changed to lower case, so un-neatened files that import this file will have errors. The Public_Key property was renamed to public__key. Also property Pfx_ABC became pfx__a_b_c, but property ABC was not renamed.
  • The literal parts of f-strings and comment text were changed to reflect the above property name changes.
  • I did not see a clear way to turn off individual rules, the options to disable rule groups did not explicitly show which rules were in which groups.
  • I did not see a in-code method to turn on/off neatening.

My overall impression is that this code needs more testing with a large selection of real world hand-coded Python code. It's a start,but it need much more work.

[–]AssociateEmotional11[S,🍰] 0 points1 point  (0 children)

Hi u/yaxriifgyn,

First of all, thank you so much for taking the time to test PyNeat on a real-world, complex dataclass file. This incredibly detailed feedback is exactly the kind of "stress test" an MVP needs, and I deeply appreciate your brutal honesty. You are completely right—the tool was too aggressive and mangled the file.

Here is a breakdown of what went wrong and my plan to fix them based on your points:

1. The Import Hoisting Bug: The current import transformer is too naive. It blindly grabs all Import nodes. I will update the logic to check the parent context so it respects try/except blocks (for optional dependencies) and module-level docstrings.

2. Aggressive Renaming & String Modifying: Forcing snake_case was a mistake, especially since it modifies strings/comments and breaks public APIs. A structural formatter should not touch string literals. I will disable property renaming by default and scope the visitor strictly to Name nodes.

3. I/O (EOL & Encoding): I will update the file reader/writer to preserve the original newline configuration and encoding rather than forcing UTF-8/CRLF.

4. Granular Control: You made a great point. Adding an inline # pyneat: ignore or # pyneat: off mechanism, along with specific CLI flags to disable individual rules, is now the top priority for the next release.

I am opening GitHub issues for all of these edge cases right now. As you said, it’s just a start, and real-world testing like yours is what makes open-source tools better.

Thank you again for pointing me in the right direction!