question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C407 increases laziness which should be noted since it can change behaviour

See original GitHub issue

The following issues the C407 warning (as desired)

results = all([m.delete() for m in q.where_in(self._other_key, ids).get()])

however if you appease it and switch the code to

results = all((m.delete() for m in q.where_in(self._other_key, ids).get()))

or

results = all(m.delete() for m in q.where_in(self._other_key, ids).get())

It causes a subtle bug due to the new laziness gained by the generator expression

This can be evidenced here

>>> all((print(i) for i in range(1, 10)))
1
False
>>> all((print(i) or True for i in range(1, 10)))
1
2
3
4
5
6
7
8
9
True

This warning should probably remind/warn (haha) the user that there is a risk in changing it to follow the warning if the generate has a side effecting function in it

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
merc1031commented, Jun 3, 2020

Yah, its tough. It seems like a decent rule, but it can bite you pretty hard. Maybe if it defaults to being ignored, and has a more strongly worded warning about its implications? That could be a good compromise.

in the haskell linter, hlint, there are a few lints that warn you that they either increase or decrease laziness.

1reaction
adamchainzcommented, Jun 3, 2020

Rule C407 has been a constant source of problems - 5 or 6 bugs in the changelog: https://github.com/adamchainz/flake8-comprehensions/blob/master/HISTORY.rst . I’m tempted to just remove it. I’d prefer this library gave 100% actionable advice rather than “sometimes this is a good idea” tweaks. What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grit (effortful persistence) can be measured with a short scale ...
Study 2 investigated how grit relates to career success (income, job prestige, job satisfaction) and career engagement (working overtime, participation in ...
Read more >
The Character of the Athenian Empire - JSTOR
garded as a supplement to his "Athenian Democracy and its Critics," in Camb. ... change to tributary status - in effect, their laziness...
Read more >
Exploring World Geography Guide for Parents and Answer Key
This course is a survey of the physical geography of the world and human geography—how humans throughout history have interacted with geography. The...
Read more >
gdb-8.2/gdb/po/gdb.pot - toolchain/gdb.git - Git at Google
msgid "Cannot switch to task %d: Task is no longer running". msgstr "" ... "Note: automatically using hardware breakpoints for read-only addresses.\n".
Read more >
The Application of Mindfulness of the Sacred Dharma / The ...
Minor killing is to kill an animal or someone of degenerate moral conduct. ... The petals are as radiant as the sun when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found