Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow doule indentation for function definitions #1050

Open
LefterisJP opened this issue Jan 15, 2023 · 3 comments
Open

Allow doule indentation for function definitions #1050

LefterisJP opened this issue Jan 15, 2023 · 3 comments

Comments

@LefterisJP
Copy link

Many projects use double indentation for function definition arguments. That is in order to allow the arguments to be clearly separated and visible.

I have not found a configuraion/knob to allow this with yapf. No matter my config it always try to go only for single indentation. How could I make the following not be changed?

     def create_oracle_cache(
-            self,
-            oracle: HistoricalPriceOracle,
-            from_asset: AssetWithOracles,
-            to_asset: AssetWithOracles,
-            purge_old: bool,
+        self,
+        oracle: HistoricalPriceOracle,
+        from_asset: AssetWithOracles,
+        to_asset: AssetWithOracles,
+        purge_old: bool,
     ) -> None:

Keep in mind the double indentation is only for function definitions. Everywhere else it should be single.

Related issue but still no solution: #843

@LefterisJP
Copy link
Author

A way around this is to use a different tool to perform this change, after yapf runs. A fork of double-indent I made seems to work fine: https://github.com/LefterisJP/double-indent

The problem is that:

  1. You need a different tool, running after yapf at --in-place mode.
  2. You can no longer use yapf to do anything but reformat (with --in-place) since it will always find the double indentation problem

@CSatSVFX
Copy link

CSatSVFX commented Mar 1, 2023

Not quite everywhere else as if statements have the same issue. It seems to be anywhere that a new code block/indentation happens, though as mentioned in that other ticket, bad continuation was removed from the more recent versions of pylint as can be seen here: pylint-dev/pylint#3571

I do understand and commiserate if you aren't able to simply update your pylint version however and still would like the flexibility.

@LefterisJP
Copy link
Author

LefterisJP commented Mar 2, 2023

I do understand and commiserate if you aren't able to simply update your pylint version however and still would like the flexibility.

What does that have to do with anything? Pylint can't auto-format your code. The issue is about yapf allowing this option as a customization.

Unless you are trying to say this kind of styling is outdated and should not be followed?

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

No branches or pull requests

2 participants