LibCST/libcst/_helpers.py
Jennifer Taylor 3dec7be6ef Export things from libcst's base__init__.py
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.
2019-07-26 12:48:22 -07:00

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