logo
Sourcery Documentation
Rule Configuration
Initializing search
    GitHub
    • Welcome to Sourcery
    • AI Code Reviews
    • IDE Coding Assistant
    • Fixing Production Issues
    GitHub
    • Welcome to Sourcery
      • Support
    • AI Code Reviews
        • GitHub
        • GitLab
        • VSCode
        • JetBrains
      • Code Review Configuration
        • FAQs
        • Troubleshooting
        • Supported Operating Systems
        • Glossary
      • Plans and Pricing
      • Privacy and Security
    • IDE Coding Assistant
      • Getting Started
        • VSCode
        • JetBrains
          • Emacs
          • Sublime
          • Vim
          • Command Line
          • pre-commit
          • CI
        • Coding Assistant Configuration
          • Configuration Sources
          • Overview
          • Rule Settings
          • Rule Configuration
          • GitHub Configuration
          • Clone Detection
          • Proxy Settings
        • Inline Configuration
        • IDE Autocompletion
          • Python
            • Default Rules
              • Assign If Expression
              • Augmented Assign
              • Avoid Builtin Shadow
              • Aware datetime For UTC
              • Binary Operator Identity
              • Boolean If Expression Identity
              • Break-Or-Continue-Outside-Loop
              • Chain Compares
              • Class Extract Method
              • Class Method First Parameter Should Be cls
              • Collection to Comprehension
              • Collection Into Set
              • Collection to Bool
              • Compare Via Equals
              • Comprehension to Generator
              • Convert Any to In
              • Convert to Enumerate
              • DataFrame Append to Concat
              • De Morgan's Laws
              • Default Get
              • Default Mutable Arguments
              • Del Comprehension
              • Dict Assign-Update to Union
              • Dictionary Comprehension
              • Dict-Literal
              • Do Not Use Bare Except
              • Dont-Import-Test-Modules
              • Ensure File Closed
              • Equality Identity
              • Extract Duplicate Method
              • Extract Method
              • Flatten Nested Try
              • Flip Comparison
              • For Append To Extend
              • For Index Replacement
              • Replace For Index with Underscore
              • Guard
              • Hoist If from If
              • Hoist Loop from If
              • Hoist Repeated If Condition
              • Hoist Similar Statements from If
              • Hoist Statements from If
              • Hoist Statement from Loop
              • Identity Comprehensions
              • Inline Immediately Returned Variables
              • Inline Immediately Yielded Variable
              • Inline Variable
              • Instance Method First Parameter Should Be self
              • Introduce Default Else
              • Invert Any/All
              • Invert Any/All in Body
              • Last if statement guard
              • Lift Duplicated Conditional
              • Lift Return into If
              • List Comprehension
              • List Literal
              • Low Code Quality
              • Max/min Default
              • Merge Assignment and Augmented Assignment
              • Merge Comparisons
              • Merge Dictionary Assignments
              • Merge Duplicate Blocks
              • Merge Else If Into Elif
              • Merge Exception Handlers
              • Merge isinstance
              • Merge List Append
              • Merge List Appends Into Extend
              • Merge List Extend
              • Merge-Nested-Ifs
              • Merge Repeated Ifs
              • Merge Set Add
              • Method_chaining
              • Min/Max identity
              • Missing Dict Items
              • Move Assign
              • Move Assign In Block
              • No-Conditionals-In-Tests
              • No-Loop-In-Tests
              • Non Equal Comparison
              • None Compare
              • Or-If-Exp-Identity
              • Pandas: Avoid inplace
              • pathlib.Path Read
              • Raise From Previous Error
              • Raise-Specific-Error
              • Reintroduce Else
              • Remove Assert True
              • Remove Dict Items
              • Remove Dictionary Keys
              • Remove Duplicate Dict Key
              • Remove Duplicate Set Key
              • Remove Empty Nested Block
              • Remove-None-From-Default-Get
              • Remove Pass From Body
              • Remove Pass From Elif
              • Remove Redundant Boolean
              • Remove Redundant Condition
              • Remove Redundant Constructor in Dict Union
              • Remove Redundant Continue
              • Remove Redundant Except Handler
              • Remove Redundant Exception
              • Remove Redundant f-string
              • Remove Redundant If Statements
              • Remove Redundant Pass
              • Remove-Redundant-Path-Exists
              • Remove Redundant Slice Index
              • Remove Str From Fstring
              • Remove str() from call to print()
              • Remove-Unit-Step-From-Range
              • Remove Unnecessary Cast
              • Remove Unnecessary Else
              • Remove Unreachable Code
              • Remove Unused Enumerate
              • Remove-Zero-From-Range
              • Replace apply With Method Call
              • Replace apply With NumPy Operation
              • Replace Dict Items with Values
              • Replace Interpolation With Fstring
              • Return or Yield Outside Function
              • Set Comprehension
              • Simplify Boolean Comparison
              • Simplify-Constant-Sum
              • Simplify Dictionary Update
              • Simplify Division
              • Simplify Empty Collection Comparison
              • Simplify f-string Formatting
              • Simplify Generator
              • Simplify Length Comparison
              • Simplify Negative Index
              • Simplify Numeric Comparison
              • Simplify Single Exception Tuple
              • Simplify String Length Comparison
              • Simplify substring search
              • Skip Sorted List Construction
              • Split or ifs
              • Square Identity
              • Str Prefix Suffix
              • Sum Comprehension
              • Swap If Else Branches
              • Swap-If-Expression
              • Swap Nested Ifs
              • Swap Variable
              • Switch
              • Ternary to If Expression
              • Tuple-Literal
              • Unwrap Iterable Construction
              • Use Any
              • Use Assigned Variable
              • Use contextlib.suppress
              • Use Count
              • Use Datetime Now Not Today
              • Use Dictionary Items
              • Use Dictionary Union
              • Use File Iterator
              • Use Fstring For Concatenation
              • Use FString For Formatting
              • Use Getitem For Re Match Groups
              • Use-Isna
              • Use itertools.product
              • Use str.join()
              • Use len()
              • Use Named Expression
              • Use Next
              • Use-Or-For-Fallback
              • Use String Remove Affix
              • Use_iloc
              • Useless-Else-On-Loop
              • While-Guard-To-Condition
              • Replace while with for
              • Yield from
            • Optional Rules
              • Google Python Style Guide
          • JavaScript
              • Assignment-Operator
              • Avoid-Function-Declarations-In-Blocks
              • Avoid-Infinite-Loops
              • Avoid-Jumping-In-Finally
              • Avoid-Using-Var
              • Binary-Operator-Identity
              • Combine-Object-Destructuring
              • Dont-Concatenate-String-Literals
              • Dont-Negate-Is-Instanceof-Operands
              • Dont-Reassign-Caught-Exceptions
              • Dont-Reassign-Foreach-Variables
              • Dont-Reassign-Parameters
              • Dont-Self-Assign-Variables
              • Dont-Shadow-Arguments
              • Dont-Use-With
              • Dont-Use-Wrappers-For-Builtins
              • Flatten-Nested-Try
              • Flip-Comparison
              • Generators-Should-Yield
              • Inline-Immediately-Returned-Variable
              • Invert-Ternary
              • Max-Min-Identity
              • Merge-Else-If
              • Merge-Nested-Ifs
              • Misplaced-Break-Or-Continue
              • No-Eval
              • No-New-Function
              • No-New-Symbol
              • Only-Delete-Object-Properties
              • Possible-Incorrect-Bitwise-Operator
              • Remove-Redundant-Boolean
              • Remove-Redundant-If-Statement
              • Remove-Redundant-Slice-Index
              • Remove-Unreachable-Code
              • Return-Outside-Function
              • Simplify-Ternary
              • Throw-New-Errors
              • Use-Array-Literal
              • Use-Braces
              • Use-Object-Destructuring
              • Use-Ternary-Operator
              • While-Guard-To-Condition
              • Yield-Outside-Generator
          • Custom Rules
            • Pattern Syntax
            • Conditions
            • Writing Custom Rules
            • Custom Rule Recipes
              • Naming Conventions
              • Package Dependencies
              • Deprecation
              • Library Dependencies
              • Hard Coded Values
              • Debug Statements
              • Library Rules
      • Code Metrics
        • FAQs
        • Troubleshooting
        • Supported Operating Systems
        • Glossary
      • Plans and Pricing
      • Privacy and Security
      • Getting Started
      • Investigating an Issue
      • Fixing and Issue
      • Configuration
        • Sentry
        • Slack

    Rule Configuration¶

    You can define project-specific rules in your Sourcery config file

    For the syntax of these rules, check out the Project-Specific Rules reference documentation

    Was this page helpful?
    Thanks for your feedback! Help us improve this page by using our feedback form.
    Thanks for your feedback! Help us improve this page by using our feedback form.
    Made with Material for MkDocs