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

WPS305 Rationale suggestion #1522

Closed
nymann opened this issue Jul 26, 2020 · 3 comments
Closed

WPS305 Rationale suggestion #1522

nymann opened this issue Jul 26, 2020 · 3 comments
Labels
documentation Docs related task feature New feature or request good first issue Entrypoint to the project help wanted Extra attention is needed

Comments

@nymann
Copy link

nymann commented Jul 26, 2020

It's my personal opinion that incorporating your own words in the readme.md

Enforce "There should be one -- and preferably only one -- obvious way to do it"

As a rationale for WPS305 is overall better.

To me (a newcomer) the current rationale in issue #32 comes of as "it's hard to lint so let's not bother". While saying there should only be one way to do something and in the case of formatting strings that's .format() is something I can get behind.

What do you think?

@sobolevn sobolevn added documentation Docs related task feature New feature or request good first issue Entrypoint to the project help wanted Extra attention is needed labels Jul 26, 2020
@sobolevn
Copy link
Member

I am open to suggestions and pull requests! 🥇

@jtpavlock
Copy link

Perhaps with the changes in #1315 a configuration option to only prefer f strings could be allowed? The use of a string formatter between f strings and .format() seems highly subjective and I don't think there is "an obvious way to do it".

@sobolevn
Copy link
Member

f strings are fundamentally more complex than .format, because:

  • they implicitly rely on the context: f'My name is {name}'. Try to rename name variable outside of the string literal and it will blow.
  • they do two things at once: defining the template and formatting it

So, f strings would never be the default. But, you can switch rules you don't like and use a custom flake8 plugin to enforce f strings in your own projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs related task feature New feature or request good first issue Entrypoint to the project help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants