Skip to content

Type ASTProcessor targets and ASTReference nodes with protocols - #273

Open
FrancescoPezzella wants to merge 6 commits into
type-parameters-docsfrom
astnode-change-minor
Open

FrancescoPezzella wants to merge 6 commits into
type-parameters-docsfrom
astnode-change-minor

Conversation

@FrancescoPezzella

@FrancescoPezzella FrancescoPezzella commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Generic code typed its node parameters as ASTNode, but only the Clang adapters subclass ASTNode. The Python RST and CST adapters and the tree-sitter adapter are duck-typed (ADR 03, ADR 06). They already worked at runtime but failed type checking against ASTProcessor and ASTReference. This PR types those APIs with the existing protocols instead, so any adapter that satisfies them type-checks.

No runtime behaviour changes: only type annotations, one TODO and test fixture annotations.

Refers to #269, partially fixes some of the issues
Relates to #149

@FrancescoPezzella FrancescoPezzella self-assigned this Oct 11, 2026
@FrancescoPezzella
FrancescoPezzella marked this pull request as ready for review October 12, 2026 09:34
@FrancescoPezzella
FrancescoPezzella changed the base branch from main to ruff-ignore-fix002 October 12, 2026 09:35
@FrancescoPezzella
FrancescoPezzella changed the base branch from ruff-ignore-fix002 to main October 12, 2026 09:37
@FrancescoPezzella
FrancescoPezzella changed the base branch from main to ruff-ignore-fix002 October 12, 2026 09:37
@FrancescoPezzella
FrancescoPezzella added this pull request to stack #277 October 12, 2026 09:37
@FrancescoPezzella

Copy link
Copy Markdown
Collaborator Author

Ci/Cd is failing even though more lint errors were solved, 6460 > 6352 (+100 issues solved). Reason for that is that solving one issue, relegated the error somewhere else, exposing another issue that was hidden by the former issue solved. In this way, I would be solving all Type errors for the rest of the days, so to keep the scope of this PR smaller, I will fix some unrelated Type errors to make Ci/Cd pass.

ruff: 2219 issues in 56 kinds, budget 2274
pyright: 6352 issues in 32 kinds, budget 6460

These kinds of issues exceed their budget:
  pyright reportUnknownArgumentType: 1175 issues, budget 1121 (+54)
  pyright reportUnknownVariableType: 895 issues, budget 891 (+4)

@FrancescoPezzella FrancescoPezzella added language agnostic Issues related to functionality that is independent of programming language or parser infrastructure issues related to the infrastructure for building, testing, and distribution labels Oct 12, 2026
@FrancescoPezzella FrancescoPezzella removed the infrastructure issues related to the infrastructure for building, testing, and distribution label Oct 12, 2026
Base automatically changed from ruff-ignore-fix002 to main October 15, 2026 08:33
Comment thread src/renaissance/syntax_tree/ast_node.py Outdated
Comment thread src/renaissance/syntax_tree/ast_processor.py

@pjljvandelaar pjljvandelaar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions raised.
But further looks good.

@FrancescoPezzella
FrancescoPezzella force-pushed the astnode-change-minor branch 2 times, most recently from 6df2aa3 to f3735fe Compare October 16, 2026 11:57
@FrancescoPezzella
FrancescoPezzella removed this pull request from stack #277 October 16, 2026 11:58
@FrancescoPezzella
FrancescoPezzella changed the base branch from main to type-parameters-docs October 16, 2026 12:10
@FrancescoPezzella
FrancescoPezzella added this pull request to stack #295 October 16, 2026 12:13
… over NodeProtocol

ASTNode now satisfies NodeProtocol, so adapters that don't subclass ASTNode (RST, CST, LST) type-check, and clang references keep their concrete node type (#269).
Overall around 10 % (600) PyRight issues solved with this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

language agnostic Issues related to functionality that is independent of programming language or parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants