Skip to content

Fix Formatting Options and VSCode autopep8 Extension#32

Merged
andig merged 2 commits into
evcc-io:mainfrom
lfloeer:fix/fix-formatting
Oct 9, 2025
Merged

Fix Formatting Options and VSCode autopep8 Extension#32
andig merged 2 commits into
evcc-io:mainfrom
lfloeer:fix/fix-formatting

Conversation

@lfloeer
Copy link
Copy Markdown
Contributor

@lfloeer lfloeer commented Oct 8, 2025

  • Remove recursive setting from pyproject.toml to be compatible with autopep8 VSCode extension
  • Sets recursive flag in make and CI
  • Fixes formatting

@andig
Copy link
Copy Markdown
Member

andig commented Oct 8, 2025

Another inconsistency? Applying autopep8 locally, this is not required. It only happens when running make. Question is why and where is the inconsistency?

@lfloeer
Copy link
Copy Markdown
Contributor Author

lfloeer commented Oct 8, 2025

There might be a difference where VSCodes' autopep8 and the command run by make source their settings. I would trust the make command one, since it's taking its settings from the pyproject.toml correctly and the CI needs to use this in any case. We can try to avoid these issues by introducing pre-commit, which I did not want to shove into the other pr as well, but I can make a separate PR for. This will fix all of these issues before committing, regardless of what IDE settings might want to force.

@lfloeer
Copy link
Copy Markdown
Contributor Author

lfloeer commented Oct 8, 2025

Okay, I've just confirmed in a code space, the autopep8 extension works differently than the uv run autopep8 command, precisely in how it treats the leading whitespace leading to the issue in this PR. Since other developers might not use VSCode, I would say we recommend using make lint to get the code into shape, as at least this is consistent and portable.

@lfloeer
Copy link
Copy Markdown
Contributor Author

lfloeer commented Oct 8, 2025

Ah, I think I've found the issue: In pyproject.toml, I set recursive = true to format all files at once. But the autotpep8 extensions reads this setting as well, but is using stdout/stdin to format code, in which case recursive is not supported, so it silently does nothing.

From the VSCode log

2025-10-08 12:27:32.513 [info] CWD Server: /workspaces/evopt
2025-10-08 12:27:32.574 [info] [Trace - 12:27:32 PM] Received notification 'window/logMessage'.
2025-10-08 12:27:32.574 [info] usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]
                [--ignore-local-config] [-r] [-j n] [-p n] [-a]
                [--experimental] [--exclude globs] [--list-fixes]
                [--ignore errors] [--select errors] [--max-line-length n]
                [--line-range line line] [--hang-closing] [--exit-code]
                [files ...]
--recursive cannot be used with standard input

@lfloeer
Copy link
Copy Markdown
Contributor Author

lfloeer commented Oct 8, 2025

Now extension, make, and CI should be consistent.

@lfloeer
Copy link
Copy Markdown
Contributor Author

lfloeer commented Oct 8, 2025

Reading my stupid "Ah" and "Okay" openings, I realize I sound like an LLM and I want to apologize for this.

@lfloeer lfloeer changed the title fix formatting Fix Formatting Options and VSCode autopep8 Extension Oct 8, 2025
@andig
Copy link
Copy Markdown
Member

andig commented Oct 8, 2025

Stream of consciousness 😂

@lfloeer
Copy link
Copy Markdown
Contributor Author

lfloeer commented Oct 9, 2025

@andig anything left to do here before we can merge this and #33 ?

@andig andig merged commit c4425ad into evcc-io:main Oct 9, 2025
2 checks passed
@andig
Copy link
Copy Markdown
Member

andig commented Oct 9, 2025

Realize I don't unterstand the python philosophy. Why are we using \ in this case and why does autopep insist on formatting this block but not the others?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants