Skip to content

Conversation

drinkmorewaterr
Copy link
Contributor

Summary

#1370

Test Plan

CI

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 3, 2025
@drinkmorewaterr drinkmorewaterr requested a review from amyreese July 5, 2025 15:03
@drinkmorewaterr drinkmorewaterr marked this pull request as ready for review July 5, 2025 15:03
@drinkmorewaterr drinkmorewaterr requested a review from zsol July 5, 2025 15:03
Copy link
Contributor

@zsol zsol left a comment

Choose a reason for hiding this comment

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

This is a good start! I would personally probably separate the change out to three PRs:

  • the entrypoints change
  • clean up tests that are no longer relevant
  • delete the old parser

But it's entirely up to you.

There are a bunch of additional stuff that can be cleaned up, like tests that get skipped with the native parser (these are typically error tests), or a large chunk of the ParserConfig and PartialParserConfig infrastructure. We could also move the utf8 conversion down to the rust layer which might help perf

def test_valid(self, **kwargs: Any) -> None:
if not is_native() and kwargs.get("native_only", False):
self.skipTest("Disabled for native parser")
if "native_only" in kwargs:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should clean these up too

parser: Optional[Callable[[str], cst.CSTNode]] = (
parse_statement if is_native() else None
)
parser: Optional[Callable[[str], cst.CSTNode]] = parse_statement
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
parser: Optional[Callable[[str], cst.CSTNode]] = parse_statement
parser: Callable[[str], cst.CSTNode] = parse_statement

}
)
def test_parser(
self, *, code: str, expected: cst.Module, enabled_for_native: bool = True
Copy link
Contributor

Choose a reason for hiding this comment

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

The enabled_for_native param should also go away

native_parse_statement: Optional[Callable[[str], cst.CSTNode]] = (
parse_statement if is_native() else None
)
native_parse_statement: Optional[Callable[[str], cst.CSTNode]] = parse_statement
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
native_parse_statement: Optional[Callable[[str], cst.CSTNode]] = parse_statement
native_parse_statement: Callable[[str], cst.CSTNode] = parse_statement

)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
Copy link
Contributor

Choose a reason for hiding this comment

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

we should delete test cases that are marked with expect_success here

parser_type = "native" if is_native() else "pure"
print(f"running tests with {parser_type!r} parser")

print("running tests with native parser")
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't necessary anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants