Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new declare-non-slot error code #9564

Merged

Commits on Apr 22, 2024

  1. Add "declare-non-slot" error code.

    - Add test case which should report the error code.
    
    - Add test case where the error is suppressed due to __dict__
      in __slots__.
    
    - Add test to detect annotation not in any base class' __slots__
    
    - Add test against false-positive when base doesn't have __slots__
      (since there is still then an instance __dict__ thanks to base)
    
    - Add test against false-positive when base has __slots__ with
      __dict__ entry
    
    Ignore declare-non-slots for regression_5479.py
    
    - This regression test is for "assigning-non-slot" so ignore
      "declare-non-slots" which also matches this example.
    
    Implement check for "declare-non-slot" and 2 new helper methods:
    
    - Add method `_check_declare_non_slot` to report "declare-non-slot" error.
      This method checks `node` and all bases for a valid `__slots__`, gathering
      the names in all `__slots__` found. If `node` has an annotation not in any
      `__slots__`, then "declare-non-slot" is reported.
    
    - Add helper method `_has_valid_slots` which returns True if a valid `__slots__`
      is found on a ClassDef (re-use logic from `_check_slots`).
    
    - Refactor `_check_redefined_slots` to split out logic for getting `__slots__`
      names into `_get_classdef_slots_names` helper.
    adamtuft committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    ac43896 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    245be58 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2024

  1. Update pylint/checkers/classes/class_checker.py

    Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
    adamtuft and DanielNoord committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    fe93eaa View commit details
    Browse the repository at this point in the history
  2. Update pylint/checkers/classes/class_checker.py

    Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
    adamtuft and Pierre-Sassoulas committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    84f1a1f View commit details
    Browse the repository at this point in the history
  3. Update pylint/checkers/classes/class_checker.py

    Avoid unnecessary inference if any ancestor has __dict__ in __slots__
    
    Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
    adamtuft and Pierre-Sassoulas committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    09c22f8 View commit details
    Browse the repository at this point in the history

Commits on May 2, 2024

  1. Configuration menu
    Copy the full SHA
    b7d0ea3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f3eede2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2f35234 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0301e23 View commit details
    Browse the repository at this point in the history
  5. Amend "declare-non-slot" to abort check if empty __slots__.

    - An empty __slots__ is required if a class takes part in multiple
      inheritance, so assume this is the case if the base class has an
      empty __slots__ and abort the check.
    
    - Abort early if __dict__ found in any __slots__.
    
    - No need to call self._has_valid_slots in
      self._get_classdef_slots_names since we already call it at the start
      of the check.
    
    - Move definition to below E0244 for consistency, remove "'" around %r
      as this adds extra quotes when formatted.
    adamtuft committed May 2, 2024
    Configuration menu
    Copy the full SHA
    654fdaa View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5a7bb6f View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    9ea4441 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    deb9d41 View commit details
    Browse the repository at this point in the history
  9. Add return type annotations

    adamtuft committed May 2, 2024
    Configuration menu
    Copy the full SHA
    cfd81c2 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    67b5d50 View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2024

  1. Configuration menu
    Copy the full SHA
    b346850 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    71f763e View commit details
    Browse the repository at this point in the history
  3. upgrade doc

    Pierre-Sassoulas committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    7080a86 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4213b1b View commit details
    Browse the repository at this point in the history

Commits on Jun 6, 2024

  1. Cover everything

    Pierre-Sassoulas committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    05e0e14 View commit details
    Browse the repository at this point in the history