diff --git a/pyproject.toml b/pyproject.toml index 14be9d2741..39890f0cd9 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 685d121a8e..1b54f7131e 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