File: categories.md

package info (click to toggle)
python-refurb 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,700 kB
  • sloc: python: 9,468; makefile: 40; sh: 6
file content (165 lines) | stat: -rw-r--r-- 4,816 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Categories

Here is a list of the built-in categories in Refurb, and their meanings.

## `abc`

These check for code relating to [Abstract Base Classes](https://docs.python.org/3/library/abc.html).

## `builtin`

Checks that have the `builtin` category cover a few different topics:

* Built-in functions such as `print()`, `open()`, `str()`, and so on
* Statements such as `del`
* File system related operations such as `open()` and `readlines()`

## `control-flow`

These checks deal with the control flow of a program, such as optimizing usage
of `return` and `continue`, removing `if` statements under certain conditions,
and so on.

## `contextlib`

These checks are for the [contextlib](https://docs.python.org/3/library/contextlib.html)
standard library module.

## `datetime`

These checks are for the [datetime](https://docs.python.org/3/library/datetime.html)
standard library module.

## `decimal`

These checks are for the [decimal](https://docs.python.org/3/library/decimal.html)
standard library module.

## `dict`

These checks cover:

* Usage of `dict` objects
* In some cases, objects supporting the [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping) protocol

## `fastapi`

These are checks relating to the third-party [FastAPI](https://github.com/tiangolo/fastapi) library.

## `fstring`

These checks relate to Python's [f-strings](https://fstring.help/).

## `fractions`

These checks are for the [fractions](https://docs.python.org/3/library/fractions.html)
standard library module.

## `functools`

These checks relate to the [functools](https://docs.python.org/3/library/functools.html)
standard library module.

## `hashlib`

These checks relate to the [hashlib](https://docs.python.org/3/library/hashlib.html)
standard library module.

## `iterable`

These checks cover:

* Iterable types such as `list` and `tuple`
* Standard library objects which are commonly iterated over such as `dict` keys

## `itertools`

These checks relate to the [itertools](https://docs.python.org/3/library/itertools.html)
standard library module.

## `math`

These checks relate to the [math](https://docs.python.org/3/library/math.html)
standard library module.

## `operator`

These checks relate to the [operator](https://docs.python.org/3/library/operator.html)
standard library module.

## `logical`

These checks relate to logical cleanups and optimizations, primarily in `if` statements,
but also in boolean expressions.

## `list`

These checks cover usage of the built-in `list` object.

## `pattern-matching`

Checks related to Python 3.10's [Structural Pattern Matching](https://peps.python.org/pep-0636/).

## `pathlib`

These checks relate to the [pathlib](https://docs.python.org/3/library/pathlib.html)
standard library module.

## `performance`

These checks are supposted to find slow code that can be written faster. The threshold for
"fast" and "slow" are somewhat arbitrary and depend on the check, but in general you should
expect that a check in the `performance` category will make your code faster (and should never
make it slower).

## `python39`, `python310`, `python311`

These checks are only enabled for Python versions 3.9, 3.10, or 3.11 respectively, or in some
way are improved in later versions of Python. For example, `isinstance(x, y) or isinstance(x, z)`
can be written as `isinstance(x, (y, z))` in any Python version, but in Python 3.10+ it can
be written as `isinstance(x, y | z)`.

## `pythonic`

This is a general catch-all for things which are "unpythonic". It differs from the
`readability` category because "unreadable" code can still be pythonic.

## `readability`

These checks aim to make existing code more readable. This can be subjective, but in general,
they reduce the horizontal or vertical length of your code, or make the underlying meaning
of the code more apparent.

## `regex`

These checks are for the [`re`](https://docs.python.org/3/library/contextlib.html) standard library module.

## `scoping`

These checks have to do with Python's scoping rules. For more info on how Python's scoping
rules work, read [this article](https://realpython.com/python-scope-legb-rule/).

## `secrets`

These checks are for the [secrets](https://docs.python.org/3/library/secrets.html)
standard library module.

## `set`

These checks deal with usage of [`set`](https://docs.python.org/3/tutorial/datastructures.html#sets)
objects in Python.

## `shlex`

These checks are for the [shlex](https://docs.python.org/3/library/shlex.html)
standard library module.

## `string`

These checks deal with usage of [`str`](https://docs.python.org/3/library/stdtypes.html#string-methods)
objects in Python.

## `truthy`

These checks cover truthy and falsy operations in Python, primarily in the context of `assert` and `if`
statements.