Skip to content

Conversation

@AlexWaygood
Copy link
Member

Summary

Add tests covering:

  • When a protocol should be considered fully static
  • When protocol instances should be considered to be always truthy, always falsy or ambiguously truthy
  • An edge case to do with validation of protocol members: it's okay for a protocol class to have an attribute assigned to without a declaration in that class if the attribute is declared in a superclass of the protocol class

Test Plan

cargo test -p red_knot_python_semantic

@AlexWaygood AlexWaygood added testing Related to testing Ruff itself ty Multi-file analysis & type inference labels Apr 24, 2025
@carljm carljm mentioned this pull request Apr 24, 2025
5 tasks
@github-actions
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅

@AlexWaygood AlexWaygood merged commit e93fa70 into main Apr 24, 2025
33 checks passed
@AlexWaygood AlexWaygood deleted the alex/more-protocol-tests branch April 24, 2025 12:11
dcreager added a commit that referenced this pull request Apr 24, 2025
* main:
  [red-knot] fix collapsing literal and its negation to object (#17605)
  [red-knot] Add more tests for protocols (#17603)
  [red-knot] Ban direct instantiations of `Protocol` classes (#17597)
  [`pyupgrade`] Preserve parenthesis when fixing native literals containing newlines (`UP018`) (#17220)
  [`airflow`] fix typos (`AIR302`, `AIR312`) (#17574)
  [red-knot] Special case `@abstractmethod` for function type (#17591)
  [red-knot] Emit diagnostics for isinstance() and issubclass() calls where a non-runtime-checkable protocol is the second argument (#17561)
  [red-knot] Infer the members of a protocol class (#17556)
  [red-knot] Add `FunctionType::to_overloaded` (#17585)
  [red-knot] Add mdtests for `global` statement (#17563)
  [syntax-errors] Make duplicate parameter names a semantic error (#17131)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants