From 193fab43571e9f1464baf72e1ec74fca570f6810 Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Thu, 25 May 2023 18:24:59 +0100 Subject: [PATCH] Switch default parser implementation to native (#929) The old parser is now only available using LIBCST_PARSER_TYPE=pure --- .github/workflows/ci.yml | 6 +++--- CHANGELOG.md | 11 +++++++++++ libcst/_parser/entrypoints.py | 2 +- native/libcst/README.md | 5 ++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab3581857..aad99e793 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,11 +40,11 @@ jobs: working-directory: native - name: Build LibCST run: hatch env create - - name: Pure Tests + - name: Tests run: hatch run test - - name: Native Tests + - name: Pure Parser Tests env: - LIBCST_PARSER_TYPE: ${{ matrix.parser }} + LIBCST_PARSER_TYPE: pure run: hatch run test # Run linters diff --git a/CHANGELOG.md b/CHANGELOG.md index 7438a9f35..aca687c21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# 1.0.0 - 2023-05-25 + +The first major release of LibCST is essentially the same as 0.4.10, but using the +newer, Rust-based parser implementation by default. The old, pure Python parser is +scheduled for removal in the next (non-patch) release. Until then, it is available with +the `LIBCST_PARSER_TYPE` environment variable set to `pure`. + +## Updated + +* Switch the default parser implementation to native by @zsol in https://github.com/Instagram/LibCST/pull/929 + # 0.4.10 - 2023-05-23 ## New Contributors diff --git a/libcst/_parser/entrypoints.py b/libcst/_parser/entrypoints.py index e47d9fc66..d9cee5e9d 100644 --- a/libcst/_parser/entrypoints.py +++ b/libcst/_parser/entrypoints.py @@ -27,7 +27,7 @@ def is_native() -> bool: typ = os.environ.get("LIBCST_PARSER_TYPE") - return typ == "native" + return typ != "pure" def _parse( diff --git a/native/libcst/README.md b/native/libcst/README.md index 2af0f1f05..09fe8f99a 100644 --- a/native/libcst/README.md +++ b/native/libcst/README.md @@ -3,9 +3,8 @@ A native extension to enable parsing of new Python grammar in LibCST. The extension is written in Rust, and exposed to Python using [PyO3](https://pyo3.rs/). -This is packaged together with libcst, and can be imported from `libcst.native`. When -the `LIBCST_PARSER_TYPE` environment variable is set to `native`, the LibCST APIs use -this module for all parsing. +This is packaged together with libcst, and can be imported from `libcst.native`. By default +the LibCST APIs use this module for all parsing. Later on, the parser library might be packaged separately as [a Rust crate](https://crates.io). Pull requests towards this are much appreciated.