mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
Go through and clean up where we export things from in the top level directories. This is the first pass at cleaning up the public API. In this diff I clean up all top-level exports that were coming out of .py files and instead export them from libcst's base module itself. I also didn't export a few of the things defined in newly underscored files because they were only used internally.
17 lines
499 B
Python
17 lines
499 B
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
# pyre-strict
|
|
from typing import Type
|
|
|
|
from libcst._visitors import CSTNodeT
|
|
|
|
|
|
def ensure_type(node: object, nodetype: Type[CSTNodeT]) -> CSTNodeT:
|
|
if not isinstance(node, nodetype):
|
|
raise Exception(
|
|
f"Expected a {nodetype.__name__} bot got a {node.__class__.__name__}!"
|
|
)
|
|
return node
|