Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ruff: Enable some new errors.

Anders Kaseorg4898fdb89dd9
diff --git a/pyproject.toml b/pyproject.toml
index 14be9d27410..39890f0cd90 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -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)
diff --git a/tools/semgrep.yml b/tools/semgrep.yml
index 685d121a8e8..1b54f7131e4 100644
--- a/tools/semgrep.yml
+++ b/tools/semgrep.yml
@@ -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