mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	ruff: Enable some new errors.
PGH001 forbids eval(). Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							17b14f5233
						
					
				
				
					commit
					b47f014ab5
				
			@@ -107,7 +107,12 @@ select = [
 | 
				
			|||||||
    "F", # flakes
 | 
					    "F", # flakes
 | 
				
			||||||
    "I", # import sorting
 | 
					    "I", # import sorting
 | 
				
			||||||
    "N", # naming
 | 
					    "N", # naming
 | 
				
			||||||
 | 
					    "PGH", # pygrep-hooks
 | 
				
			||||||
 | 
					    "PLC", # pylint convention
 | 
				
			||||||
 | 
					    "PLE", # pylint error
 | 
				
			||||||
 | 
					    "PLR", # pylint refactor
 | 
				
			||||||
    "RUF", # Ruff
 | 
					    "RUF", # Ruff
 | 
				
			||||||
 | 
					    "T10", # debugger
 | 
				
			||||||
    "UP", # upgrade
 | 
					    "UP", # upgrade
 | 
				
			||||||
    "W", # style warnings
 | 
					    "W", # style warnings
 | 
				
			||||||
    "YTT", # sys.version
 | 
					    "YTT", # sys.version
 | 
				
			||||||
@@ -117,7 +122,7 @@ ignore = [
 | 
				
			|||||||
    "ANN102", # Missing type annotation for `cls` in classmethod
 | 
					    "ANN102", # Missing type annotation for `cls` in classmethod
 | 
				
			||||||
    "ANN401", # Dynamically typed expressions (typing.Any) are disallowed
 | 
					    "ANN401", # Dynamically typed expressions (typing.Any) are disallowed
 | 
				
			||||||
    "B007", # Loop control variable not used within the loop body
 | 
					    "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
 | 
					    "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
 | 
					    "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)
 | 
					    "C408", # Unnecessary `dict` call (rewrite as a literal)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -101,36 +101,18 @@ rules:
 | 
				
			|||||||
  - id: mutable-default-type
 | 
					  - id: mutable-default-type
 | 
				
			||||||
    languages: [python]
 | 
					    languages: [python]
 | 
				
			||||||
    pattern-either:
 | 
					    pattern-either:
 | 
				
			||||||
      - pattern: |
 | 
					 | 
				
			||||||
          def $F(..., $A: typing.List[...] = [...], ...) -> ...:
 | 
					 | 
				
			||||||
              ...
 | 
					 | 
				
			||||||
      - pattern: |
 | 
					 | 
				
			||||||
          def $F(..., $A: typing.Optional[typing.List[...]] = [...], ...) -> ...:
 | 
					 | 
				
			||||||
              ...
 | 
					 | 
				
			||||||
      - pattern: |
 | 
					      - pattern: |
 | 
				
			||||||
          def $F(..., $A: typing.List[...] = zerver.lib.request.REQ(..., default=[...], ...), ...) -> ...:
 | 
					          def $F(..., $A: typing.List[...] = zerver.lib.request.REQ(..., default=[...], ...), ...) -> ...:
 | 
				
			||||||
              ...
 | 
					              ...
 | 
				
			||||||
      - pattern: |
 | 
					      - pattern: |
 | 
				
			||||||
          def $F(..., $A: typing.Optional[typing.List[...]] = zerver.lib.request.REQ(..., default=[...], ...), ...) -> ...:
 | 
					          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: |
 | 
					      - pattern: |
 | 
				
			||||||
          def $F(..., $A: typing.Dict[...] = zerver.lib.request.REQ(..., default={}, ...), ...) -> ...:
 | 
					          def $F(..., $A: typing.Dict[...] = zerver.lib.request.REQ(..., default={}, ...), ...) -> ...:
 | 
				
			||||||
              ...
 | 
					              ...
 | 
				
			||||||
      - pattern: |
 | 
					      - pattern: |
 | 
				
			||||||
          def $F(..., $A: typing.Optional[typing.Dict[...]] = zerver.lib.request.REQ(..., default={}, ...), ...) -> ...:
 | 
					          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
 | 
					    severity: ERROR
 | 
				
			||||||
    message: "Guard mutable default with read-only type (Sequence, Mapping, AbstractSet)"
 | 
					    message: "Guard mutable default with read-only type (Sequence, Mapping, AbstractSet)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -143,12 +125,6 @@ rules:
 | 
				
			|||||||
    severity: ERROR
 | 
					    severity: ERROR
 | 
				
			||||||
    message: "Prefer f-strings or .format for string formatting"
 | 
					    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
 | 
					  - id: typing-text
 | 
				
			||||||
    languages: [python]
 | 
					    languages: [python]
 | 
				
			||||||
    pattern: typing.Text
 | 
					    pattern: typing.Text
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user