Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ jobs:
run: uv sync --locked --dev
- name: Native Parser Tests
run: uv run poe test
- name: Pure Parser Tests
env:
COVERAGE_FILE: .coverage.pure
LIBCST_PARSER_TYPE: pure
run: uv run poe test
- name: Coverage
run: |
uv run coverage combine .coverage.pure
uv run coverage report
run: uv run coverage report

# Run linters
lint:
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -1184,7 +1183,7 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)

Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_binary_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -189,4 +188,4 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_parse_error(self, **kwargs: Any) -> None:
self.assert_parses(**kwargs, expect_success=not is_native())
self.assert_parses(**kwargs, expect_success=False)
3 changes: 0 additions & 3 deletions libcst/_nodes/tests/test_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -210,8 +209,6 @@ def test_valid(self, **kwargs: Any) -> None:
)
)
def test_valid_native(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled for pure python parser")
self.validate_node(**kwargs)

@data_provider(
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -188,6 +187,6 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
11 changes: 1 addition & 10 deletions libcst/_nodes/tests/test_funcdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock, parse_statement_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -741,8 +740,6 @@ class FunctionDefCreationTest(CSTNodeTest):
)
)
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

kwargs.pop("native_only")
self.validate_node(**kwargs)
Expand Down Expand Up @@ -891,8 +888,6 @@ def test_valid(self, **kwargs: Any) -> None:
)
)
def test_valid_native(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled for pure python parser")
self.validate_node(**kwargs)

@data_provider(
Expand Down Expand Up @@ -2223,8 +2218,6 @@ def test_valid(self, node: cst.CSTNode, code: str) -> None:
)
)
def test_valid_38(self, node: cst.CSTNode, code: str, **kwargs: Any) -> None:
if not is_native() and kwargs.get("native_only", False):
self.skipTest("disabled for pure python parser")
self.validate_node(node, code, _parse_statement_force_38)

@data_provider(
Expand Down Expand Up @@ -2252,7 +2245,7 @@ def test_valid_38(self, node: cst.CSTNode, code: str, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)

Expand All @@ -2271,6 +2264,4 @@ def test_versions(self, **kwargs: Any) -> None:
)
)
def test_parse_error(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Skipped for non-native parser")
self.assert_parses(**kwargs, expect_success=False, parser=parse_statement)
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression, parse_statement
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -126,6 +125,6 @@ def test_invalid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
5 changes: 1 addition & 4 deletions libcst/_nodes/tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.testing.utils import data_provider

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



class MatchTest(CSTNodeTest):
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_matrix_multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
parse_expression_as,
parse_statement_as,
)
from libcst._parser.entrypoints import is_native
from libcst.testing.utils import data_provider


Expand Down Expand Up @@ -70,6 +69,6 @@ def test_valid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_module, parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange, MetadataWrapper, PositionProvider
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -117,7 +116,7 @@ def test_code_for_node(
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

) -> None:
if is_native() and not enabled_for_native:
if not enabled_for_native:
self.skipTest("Disabled for native parser")
self.assertEqual(parse_module(code), expected)

Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.testing.utils import data_provider


Expand Down Expand Up @@ -133,6 +132,6 @@ def test_invalid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
5 changes: 1 addition & 4 deletions libcst/_nodes/tests/test_try.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

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



class TryTest(CSTNodeTest):
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression, parse_statement
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -286,6 +285,6 @@ def test_invalid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
5 changes: 0 additions & 5 deletions libcst/_nodes/tests/test_type_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -132,8 +131,6 @@ class TypeAliasCreationTest(CSTNodeTest):
)
)
def test_valid(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled in the old parser")
self.validate_node(**kwargs)


Expand Down Expand Up @@ -252,6 +249,4 @@ class TypeAliasParserTest(CSTNodeTest):
)
)
def test_valid(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled in the old parser")
self.validate_node(**kwargs)
14 changes: 6 additions & 8 deletions libcst/_nodes/tests/test_with.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

import libcst as cst
from libcst import parse_statement, PartialParserConfig
from libcst._maybe_sentinel import MaybeSentinel
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock, parse_statement_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -187,14 +185,14 @@ class WithTest(CSTNodeTest):
cst.WithItem(
cst.Call(
cst.Name("context_mgr"),
lpar=() if is_native() else (cst.LeftParen(),),
rpar=() if is_native() else (cst.RightParen(),),
lpar=(),
rpar=(),
)
),
),
cst.SimpleStatementSuite((cst.Pass(),)),
lpar=(cst.LeftParen() if is_native() else MaybeSentinel.DEFAULT),
rpar=(cst.RightParen() if is_native() else MaybeSentinel.DEFAULT),
lpar=(cst.LeftParen()),
rpar=(cst.RightParen()),
whitespace_after_with=cst.SimpleWhitespace(""),
),
"code": "with(context_mgr()): pass\n",
Expand Down Expand Up @@ -233,7 +231,7 @@ class WithTest(CSTNodeTest):
rpar=cst.RightParen(whitespace_before=cst.SimpleWhitespace(" ")),
),
"code": ("with ( foo(),\n" " bar(), ): pass\n"), # noqa
"parser": parse_statement if is_native() else None,
"parser": parse_statement,
"expected_position": CodeRange((1, 0), (2, 21)),
},
)
Expand Down Expand Up @@ -310,7 +308,7 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)

Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest, parse_statement_as
from libcst._parser.entrypoints import is_native
from libcst.helpers import ensure_type
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider
Expand Down Expand Up @@ -241,6 +240,6 @@ def test_valid(
)
)
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

self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
53 changes: 0 additions & 53 deletions libcst/_parser/_parsing_check.py

This file was deleted.

Loading
Loading