Skip to content

Commit de56353

Browse files
fix: circular import error (#1406)
* fix: circular import error
1 parent 47cacb6 commit de56353

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

libcst/_parser/entrypoints.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from functools import partial
1313
from typing import Union
1414

15-
from libcst import native
1615
from libcst._nodes.base import CSTNode
1716
from libcst._nodes.expression import BaseExpression
1817
from libcst._nodes.module import Module
@@ -34,6 +33,8 @@ def _parse(
3433

3534
encoding, source_str = convert_to_utf8(source, partial=config)
3635

36+
from libcst import native
37+
3738
if entrypoint == "file_input":
3839
parse = partial(native.parse_module, encoding=encoding)
3940
elif entrypoint == "stmt_input":

libcst/tests/test_import.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
7+
from unittest import TestCase
8+
9+
10+
class TestImport(TestCase):
11+
def test_import_libcst(self) -> None:
12+
import libcst # noqa: F401

0 commit comments

Comments
 (0)