mirror of https://github.com/zulip/zulip.git
ruff: Enable some new errors.
PGH001 forbids eval(). Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
4051435c2a
commit
4898fdb89d
|
@ -107,7 +107,12 @@ select = [
|
|||
"F", # flakes
|
||||
"I", # import sorting
|
||||
"N", # naming
|
||||
"PGH", # pygrep-hooks
|
||||
"PLC", # pylint convention
|
||||
"PLE", # pylint error
|
||||
"PLR", # pylint refactor
|
||||
"RUF", # Ruff
|
||||
"T10", # debugger
|
||||
"UP", # upgrade
|
||||
"W", # style warnings
|
||||
"YTT", # sys.version
|
||||
|
@ -117,7 +122,7 @@ ignore = [
|
|||
"ANN102", # Missing type annotation for `cls` in classmethod
|
||||
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
|
||||
"B007", # Loop control variable not used within the loop body
|
||||
"B008", # Do not perform function calls in argument defaults.
|
||||
"B008", # Do not perform function calls in argument defaults
|
||||
"B023", # Function definition does not bind loop variable
|
||||
"B904", # Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
|
||||
"C408", # Unnecessary `dict` call (rewrite as a literal)
|
||||
|
|
|
@ -101,36 +101,18 @@ rules:
|
|||
- id: mutable-default-type
|
||||
languages: [python]
|
||||
pattern-either:
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.List[...] = [...], ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Optional[typing.List[...]] = [...], ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.List[...] = zerver.lib.request.REQ(..., default=[...], ...), ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Optional[typing.List[...]] = zerver.lib.request.REQ(..., default=[...], ...), ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Dict[...] = {}, ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Optional[typing.Dict[...]] = {}, ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Dict[...] = zerver.lib.request.REQ(..., default={}, ...), ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Optional[typing.Dict[...]] = zerver.lib.request.REQ(..., default={}, ...), ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Set[...] = set(), ...) -> ...:
|
||||
...
|
||||
- pattern: |
|
||||
def $F(..., $A: typing.Optional[typing.Set[...]] = set(), ...) -> ...:
|
||||
...
|
||||
severity: ERROR
|
||||
message: "Guard mutable default with read-only type (Sequence, Mapping, AbstractSet)"
|
||||
|
||||
|
@ -143,12 +125,6 @@ rules:
|
|||
severity: ERROR
|
||||
message: "Prefer f-strings or .format for string formatting"
|
||||
|
||||
- id: eval
|
||||
languages: [python]
|
||||
pattern: eval
|
||||
severity: ERROR
|
||||
message: "Do not use eval under any circumstances; consider json.loads instead"
|
||||
|
||||
- id: typing-text
|
||||
languages: [python]
|
||||
pattern: typing.Text
|
||||
|
|
Loading…
Reference in New Issue