# Ignoring flake8 E741 rule

**URL:** https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357
**Category:** Organisation
**Created:** [October 15, 2020, 8:56am UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357 "2020-10-15T08:56:40Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 15, 2020, 8:56am UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/1 "2020-10-15T08:56:41Z")

</div>

On new version of flake8, the rule [E741](https://www.flake8rules.com/rules/E741.html) has been implemented. We have a lot of code which use `l` as list comprehension variable (when iterate on lines).  
Personally I do not find those rules relevant because the similarity between the letters depend a lot of the font used. For example I use the [Liberation Mono](https://en.wikipedia.org/wiki/Liberation_fonts) for which the `I` is quite different from the `l` and `0` has a dot in the middle to distinct from `O`. But other fonts may make other letter appears similar. I think it is the responsibility of the developer to choose a good font for coding.  
So I propose to make reviewbot ignoring this rule.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [October 15, 2020, 12:11pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/2 "2020-10-15T12:11:43Z")

</div>

Makes sense for me.  
I prefer to ignore the rule than changing all `l` to `lines` which will be hard and it may lead to some errors.

---

<div class="post-metadata">

### Author: ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)
#### Post date: [October 15, 2020, 3:45pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/3 "2020-10-15T15:45:04Z")

</div>

I have no problem with `l` when it is used in list/set/dict comprehensions. I think a combination of the small scope it is used in, and the fact that it is often seen along with an attribute (e.g.: `l.debit`) means that it is pretty hard to misread it as a `1`, regardless of which font it is in. I can understand the concern behind rule E741, but list comprehensions are meant to be concise and for me it makes sense to use `l` as the abbreviation of `line`, rather than some other random letter.

It does look like it is used in some other places, and I may be in favour of updating some of these to use more descriptive variable names, but only if it doesn’t affect how readable the code is.

- [https://hg.tryton.org/modules/country/file/5414b3708bad/scripts/import\_countries.py#l35](https://hg.tryton.org/modules/country/file/5414b3708bad/scripts/import_countries.py#l35)
- [https://hg.tryton.org/modules/stock/file/b4ac30c45a50/move.py#l1541](https://hg.tryton.org/modules/stock/file/b4ac30c45a50/move.py#l1541)
- [https://hg.tryton.org/modules/stock/file/b4ac30c45a50/move.py#l1550](https://hg.tryton.org/modules/stock/file/b4ac30c45a50/move.py#l1550)
- [https://hg.tryton.org/modules/sale\_advance\_payment/file/7786322a29a1/sale.py#l268](https://hg.tryton.org/modules/sale_advance_payment/file/7786322a29a1/sale.py#l268)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 15, 2020, 4:11pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/4 "2020-10-15T16:11:24Z")

</div>

I agree that variables with a scope larger than a x-comprehension should not be of one symbol (except for index loop like `i` and `j`).  
I do not think we need to update the cases you find just for the sake of following the rule. But if there is another change impacting them, we should take the chance to change them.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 16, 2020, 4:05pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/5 "2020-10-16T16:05:48Z")

</div>

So I [updated the website](https://hg.tryton.org/www.tryton.org/rev/2df1fa0fa31b) and updated the flake8 configuration of reviewbot.

---

<div class="post-metadata">

### Author: ![Alnus](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/alnus/32/1009_2.png) [@Alnus](https://discuss.tryton.org/u/Alnus)
#### Post date: [October 16, 2020, 5:04pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/6 "2020-10-16T17:04:03Z")

</div>

Hello,  
As per the previous update from updated from flake8 configuration of reviewbot. The patch reload [https://codereview.tryton.org/292421003/#ps310751002](https://codereview.tryton.org/292421003/#ps310751002), =\> (ambiguous variable name ‘l’) is the expected response from reviewbot.

Or this has nothing to do with it?

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [October 16, 2020, 5:12pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/7 "2020-10-16T17:12:22Z")

</div>

Should we update the .flake8 file of each repository?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 16, 2020, 5:12pm UTC](https://discuss.tryton.org/t/ignoring-flake8-e741-rule/3357/8 "2020-10-16T17:12:34Z")

</div>

Indeed I need to update `.flake8` of all repositories.
