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
python3.9: forbid anything, but dotted names inside decorators #1241
Comments
I would argue the PEP does provide a good example use case:
vs having to do
The second one looks confusing and hacky in my opinion, and I'm glad the PEP was accepted. That said, I agree complex decorator expressions would destroy readability. Perhaps requiring a low complexity for decorator expressions might be a more measured solution than a blanket ban? |
@lewisacidic I am glad that you brought this up! Let me explain the problem in this PEP example. When you write First, We can also use the alternative approach: def spam():
...
buttons[0].clicked.connect(spam)
# or even `for button in buttons: button.clicked.connect(spam)` That's why we won't allow this syntax. It is broken by the very core idea. |
I agree it is not a fantastic example, the variable name @buttons["registration"].clicked.connect
def spam():
... I do think index notation is more succinct and doesn't compromise readability in some contexts. In any case, thanks for clarifying the reasoning behind this issue: it's a matter of enforcing explicit variable naming, rather than avoiding messy expressions as decorators which was my interpretation from the initial comment. I'll respectfully probably disable this rule as and when it lands. Off topic, but thanks for your work on this library! |
Hello, could i take this one? |
Nope, sorry. python3.9 is not even released. Let's wait 🙂 |
Rule request
Thesis
After
python3.9
we would be able to use this as a decorator:WHAT?! WHY?!
We need to add a rule that forbids it.
Only names, attributes, and calls should be allowed after
@
Reasoning
This is an extra complexity that is totally not required. I don't have any valid use-cases for this.
Use variables, functions, attributes. It is not that hard!
Related: https://www.python.org/dev/peps/pep-0614/
The text was updated successfully, but these errors were encountered: