Commit Graph

14 Commits

Author SHA1 Message Date
Dylan Baker bca6c670c3 pylintrc: add function-redefined 2021-09-24 18:48:48 -07:00
Dylan Baker 9795323b86 pylint: check for duplicate imports
I ran into one of these from LGTM, and it would be nice if pylint could
warn me as part of my local development process instead of waiting for
the CI to tell me.
2021-09-24 10:36:05 -07:00
Dylan Baker b60bd0e299 pyllint: enable consider-user-enumerate
This caught a couple of cases of us doing:
```python
for i in range(len(x)):
   v = x[i]
```
which are places to use enumerate instead.

It also caught a couple of cases of:
```python
assert len(x) == len(y)
for i in range(len(x)):
    xv = x[i]
    yv = y[i]
```
Which should instead be using zip()
```python
for xv, yv in zip(x, y):
    ...
```
2021-08-31 16:28:54 -04:00
Dylan Baker 06fdb29daa pylint: turn on superfluous parens warning
Which is really useful for catching parens used with keywords like
assert. Don't use parens with assert, it's bad.
2021-08-31 16:28:54 -04:00
Dylan Baker 278942a447 pylint: enable consider-iterating-dictionary
This didn't actually catch what it's supposed to, which is cases of:
```python
for x in dict.keys():
    y = dict[x]
```
But it did catch one unnecessary use of keys(), and one case where we
were doing something in an inefficient way. I've rewritten:
```python
if name.value in [x.value for x in self.kwargs.keys() if isinstance(x, IdNode)]:
```
as
``python
if any((isinstance(x, IdNode) and name.value == x.value) for x in self.kwargs):
```
Which avoids doing two iterations, one to build the list, and a
second to do a search for name.value in said list, which does a single
short circuiting walk, as any returns as soon as one check returns True.
2021-08-31 16:28:54 -04:00
Dylan Baker 1fc3d8608d pylint: enable unnecessary-not check
This finds things like
```python
if not x == 1:
```
which should be
```python
if x != 1:
```
2021-08-31 16:28:54 -04:00
Luke Drummond 63814543de Bare exceptions are no longer allowed [NFC]
The last instances of

    try:
        ...
    except:
        ...

were removed in bf98ffca. The sideci.yml file was updated, but the
flake8 config still allows this. Ensure that flake8 tests fail if this
questionable construct appears again.
2020-11-04 12:24:48 +02:00
Dylan Baker 8fa0548e08 pylint: turn on a few more errors 2020-09-22 17:57:03 -07:00
Dylan Baker f342efd080 pylint: turn on bad-indentation error
and fix all of the bad indentation
2020-09-22 17:57:03 -07:00
Dylan Baker 3b292a04b8 pylint: turn on warnings for abstract classes
We're using these now, so having some error checking to make sure we
don't have paths were we're trying to instantiate an abstract class
would be good.
2020-09-22 17:57:03 -07:00
Dylan Baker b034f8cf61 pylint: Turn on warnings for incorrect number of args
This catches some very real errors.

The one in scalapack is pretty silly actually, it's failing to figure
out that the exploded list is at least two arguments. However, the code
is actually clearer by not using a list and exploding it, so I've done
that and pylint is happy too.
2020-09-22 17:57:03 -07:00
Dylan Baker 007ece4659 pylint: Turn on a few more good warnings 2020-09-18 14:49:58 -07:00
Dylan Baker cb0265a6b2 pylint: Catch cases of `if len(container)` which should be replaced by `if container`
Unfortunately this doesn't catch other abuses of len(continauer) like,
`len(container) <comparator> 0`, see: https://github.com/PyCQA/pylint/issues/3751
2020-09-18 14:49:58 -07:00
Michael Hirsch, Ph.D fa38aa378e add pylint config file. update Sider CI name 2019-08-02 14:31:22 +03:00