Skip to content

Conversation

@joce
Copy link
Contributor

@joce joce commented Oct 25, 2025

Fixes #40

Summary

Adds missing return statement in transform() function to comply with Astroid's transform contract.

Problem

The transform() function currently returns None implicitly in most cases, which can break the transform chain when other plugins with FunctionDef transforms are loaded after pylint-pydantic.

Changes

  • Added return node statement at line 78
  • Ensures the function always returns the node, even when unmodified
  • Consistent with how transform_pydantic_json() already handles returns in the same file

Testing

  • All existing tests pass
  • Verified transform chaining works correctly with multiple plugins loaded in different orders

Related

Impact

  • Current behaviour: Works when plugin is loaded last (typical case)
  • Fixed behaviour: Also works correctly when loaded before other transform-based plugins
  • Risk: None - this is a safe, defensive fix that only improves correctness

The transform() function was missing a return statement, which caused it
to implicitly return None in most cases. According to Astroid's transform
contract, transforms should always return the node (even if unmodified) to
ensure the transform chain continues properly.

Without this fix:
- When the condition is False, the function returns None
- This breaks the transform chain for subsequent transforms
- Related to astroid issue #809

This fix ensures the transform always returns the node, allowing other
plugins' transforms to execute correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@fcfangcc
Copy link
Owner

@joce LGTM!
I will release a new version

@fcfangcc fcfangcc merged commit 71bc8c8 into fcfangcc:main Oct 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transform() should return node to maintain transform chain

2 participants