id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
4,880
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,881
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,882
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,883
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,884
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,885
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,886
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,887
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,888
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,889
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,890
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,891
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,892
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,893
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,894
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,895
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,896
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,897
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,898
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,899
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,900
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,901
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,902
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,903
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,904
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,905
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,906
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,907
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,908
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,909
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,910
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,911
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,912
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,913
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,914
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,915
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,916
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,917
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,918
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,919
import re import typing from tokenize import ( Floatnumber as FLOATNUMBER_RE, Imagnumber as IMAGNUMBER_RE, Intnumber as INTNUMBER_RE, ) from libcst._exceptions import PartialParserSyntaxError from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.expression import ( Arg, Asynchronous, ...
null
4,920
from typing import Any, Sequence from libcst._nodes.module import Module from libcst._nodes.whitespace import NEWLINE_RE from libcst._parser.production_decorator import with_production from libcst._parser.types.config import ParserConfig class Module(CSTNode): """ Contains some top-level information inferred f...
null
4,921
import abc from dataclasses import asdict, dataclass from typing import Any, FrozenSet, Mapping, Sequence from libcst._parser.parso.utils import PythonVersionInfo class ParserConfig(BaseWhitespaceParserConfig): """ An internal configuration object that the python parser passes around. These values are globa...
An internal helper function used by unit tests to compare configs.
4,922
import codecs import re import sys from dataclasses import dataclass, field, fields from enum import Enum from typing import Any, Callable, FrozenSet, List, Mapping, Optional, Pattern, Union from libcst._add_slots import add_slots from libcst._nodes.whitespace import NEWLINE_RE from libcst._parser.parso.utils import pa...
null
4,923
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Used when you want to match exactly one node, but you do not care what node it is. Useful inside sequences such as a :class:`libcst.matchers.Call`'s args attribte. You do not need to use this for concrete matcher attributes since :func:`DoNotCare` is already the default. For example, the following matcher would match a...
4,924
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Used as a convenience wrapper to :class:`MatchIfTrue` which allows for matching a string attribute against a regex. ``regex`` can be any regular expression string or a compiled ``Pattern``. This uses Python's re module under the hood and is compatible with syntax documented on `docs.python.org <https://docs.python.org/...
4,925
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Used as a convenience wrapper to :class:`AtLeastN` when ``n`` is equal to ``0``. Use this when you want to match against any number of nodes in a sequence. For example, this will match any function call with zero or more arguments, as long as all of the arguments are integers:: m.Call(args=[m.ZeroOrMore(m.Arg(m.Integer...
4,926
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Used as a convenience wrapper to :class:`AtMostN` when ``n`` is equal to ``1``. This is effectively a maybe clause. For example, this will match any function call with zero or one integer argument:: m.Call(args=[m.ZeroOrOne(m.Arg(m.Integer()))]) This will match any function call that has two or three arguments, and the...
4,927
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Matcher helper that inverts the match result of its child. You can also invert a matcher by using Python's bitwise invert operator on concrete matchers or any special matcher. For example, the following matches against any identifier that isn't ``True``/``False``:: m.DoesNotMatch(m.OneOf(m.Name("True"), m.Name("False")...
4,928
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Matcher helper that captures the matched node that matched against a matcher class, making it available in the dictionary returned by :func:`extract` or :func:`extractall`. For example, the following will match against any binary operation whose left and right operands are not integers, saving those expressions for lat...
4,929
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Given an arbitrary node from a LibCST tree and an arbitrary matcher, iterates over that node and all children returning a sequence of all child nodes that match the given matcher. Note that the tree can also be a :class:`~libcst.RemovalSentinel` or a :class:`~libcst.MaybeSentinel` in order to use findall directly on tr...
4,930
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Given an arbitrary node from a LibCST tree and an arbitrary matcher, iterates over that node and all children returning a sequence of dictionaries representing the saved and extracted children specified by :func:`SaveMatchedNode` for each match found in the tree. This is analogous to running a :func:`findall` over a tr...
4,931
import collections.abc import inspect import re from abc import ABCMeta from dataclasses import dataclass, fields from enum import auto, Enum from typing import ( Callable, cast, Dict, Generic, Iterator, List, Mapping, NoReturn, Optional, Pattern, Sequence, Tuple, Typ...
Given an arbitrary node from a LibCST tree and an arbitrary matcher, iterates over that node and all children and replaces each node that matches the supplied matcher with a supplied replacement. Note that the replacement can either be a valid node type, or a callable which takes the matched node and a dictionary of an...
4,932
from typing import Callable, TypeVar from libcst.matchers._matcher_base import BaseMatcherNode _CSTVisitFuncT = TypeVar("_CSTVisitFuncT") VISIT_POSITIVE_MATCHER_ATTR: str = "_call_if_inside_matcher" class BaseMatcherNode: """ Base class that all concrete matchers subclass from. :class:`OneOf` and :class:`A...
A decorator for visit and leave methods inside a :class:`MatcherDecoratableTransformer` or a :class:`MatcherDecoratableVisitor`. A method that is decorated with this decorator will only be called if it or one of its parents matches the supplied matcher. Use this to selectively gate visit and leave methods to be called ...
4,933
from typing import Callable, TypeVar from libcst.matchers._matcher_base import BaseMatcherNode _CSTVisitFuncT = TypeVar("_CSTVisitFuncT") VISIT_NEGATIVE_MATCHER_ATTR: str = "_call_if_not_inside_matcher" class BaseMatcherNode: """ Base class that all concrete matchers subclass from. :class:`OneOf` and :clas...
A decorator for visit and leave methods inside a :class:`MatcherDecoratableTransformer` or a :class:`MatcherDecoratableVisitor`. A method that is decorated with this decorator will only be called if it or one of its parents does not match the supplied matcher. Use this to selectively gate visit and leave methods to be ...
4,934
from typing import Callable, TypeVar from libcst.matchers._matcher_base import BaseMatcherNode _CSTVisitFuncT = TypeVar("_CSTVisitFuncT") CONSTRUCTED_VISIT_MATCHER_ATTR: str = "_visit_matcher" class BaseMatcherNode: """ Base class that all concrete matchers subclass from. :class:`OneOf` and :class:`AllOf` ...
A decorator that allows a method inside a :class:`MatcherDecoratableTransformer` or a :class:`MatcherDecoratableVisitor` visitor to be called when visiting a node that matches the provided matcher. Note that you can use this in combination with :func:`call_if_inside` and :func:`call_if_not_inside` decorators. Unlike ex...
4,935
from typing import Callable, TypeVar from libcst.matchers._matcher_base import BaseMatcherNode _CSTVisitFuncT = TypeVar("_CSTVisitFuncT") CONSTRUCTED_LEAVE_MATCHER_ATTR: str = "_leave_matcher" class BaseMatcherNode: """ Base class that all concrete matchers subclass from. :class:`OneOf` and :class:`AllOf` ...
A decorator that allows a method inside a :class:`MatcherDecoratableTransformer` or a :class:`MatcherDecoratableVisitor` visitor to be called when leaving a node that matches the provided matcher. Note that you can use this in combination with :func:`call_if_inside` and :func:`call_if_not_inside` decorators. There is n...
4,936
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,937
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,938
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,939
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,940
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,941
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,942
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,943
from inspect import ismethod, signature from typing import ( Any, Callable, cast, Dict, get_type_hints, List, Optional, Sequence, Set, Tuple, Type, Union, ) import libcst as cst from libcst import CSTTransformer, CSTVisitor from libcst._types import CSTNodeT from libcst.m...
null
4,944
import argparse import ast import builtins import dataclasses import functools import sys from typing import cast, Dict, List, Optional, Sequence, Set, Tuple, Union from typing_extensions import TypeAlias import libcst as cst import libcst.matchers as m from libcst.codemod import CodemodContext, VisitorBasedCodemodComm...
null
4,945
import argparse import ast import builtins import dataclasses import functools import sys from typing import cast, Dict, List, Optional, Sequence, Set, Tuple, Union from typing_extensions import TypeAlias import libcst as cst import libcst.matchers as m from libcst.codemod import CodemodContext, VisitorBasedCodemodComm...
null
4,946
import argparse import ast import builtins import dataclasses import functools import sys from typing import cast, Dict, List, Optional, Sequence, Set, Tuple, Union from typing_extensions import TypeAlias import libcst as cst import libcst.matchers as m from libcst.codemod import CodemodContext, VisitorBasedCodemodComm...
Remove the type comment while keeping any following comments.
4,947
import argparse import ast import builtins import dataclasses import functools import sys from typing import cast, Dict, List, Optional, Sequence, Set, Tuple, Union from typing_extensions import TypeAlias import libcst as cst import libcst.matchers as m from libcst.codemod import CodemodContext, VisitorBasedCodemodComm...
null
4,948
import argparse from typing import Callable, Optional, Sequence, Set, Tuple, Union import libcst as cst from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand from libcst.codemod.visitors import AddImportsVisitor, RemoveImportsVisitor from libcst.helpers import get_full_name_for_node from libcst.metadata...
null
4,949
import argparse import ast from typing import Generator, List, Optional, Sequence, Set, Tuple import libcst as cst import libcst.matchers as m from libcst.codemod import ( CodemodContext, ContextAwareTransformer, ContextAwareVisitor, VisitorBasedCodemodCommand, ) def _get_lhs(field: cst.BaseExpression) ...
null
4,950
import argparse import ast from typing import Generator, List, Optional, Sequence, Set, Tuple import libcst as cst import libcst.matchers as m from libcst.codemod import ( CodemodContext, ContextAwareTransformer, ContextAwareVisitor, VisitorBasedCodemodCommand, ) def _get_field(formatstr: str) -> Tuple[...
null
4,951
import itertools import re from typing import Callable, cast, List, Sequence import libcst as cst import libcst.matchers as m from libcst.codemod import VisitorBasedCodemodCommand def _match_simple_string(node: cst.CSTNode) -> bool: if isinstance(node, cst.SimpleString) and not node.prefix.lower().startswith("b"):...
null
4,952
import itertools import re from typing import Callable, cast, List, Sequence import libcst as cst import libcst.matchers as m from libcst.codemod import VisitorBasedCodemodCommand USE_FSTRING_SIMPLE_EXPRESSION_MAX_LENGTH = 30 def _gen_match_simple_expression(module: cst.Module) -> Callable[[cst.CSTNode], bool]: de...
null
4,953
import difflib import os.path import re import subprocess import sys import time import traceback from dataclasses import dataclass, replace from multiprocessing import cpu_count, Pool from pathlib import Path from typing import Any, AnyStr, cast, Dict, List, Optional, Sequence, Union from libcst import parse_module, P...
Given a list of files or directories (can be intermingled), return a list of all python files that exist at those locations. If ``include_stubs`` is ``True``, this will include ``.py`` and ``.pyi`` stub files. If it is ``False``, only ``.py`` files will be included in the returned list.
4,954
import difflib import os.path import re import subprocess import sys import time import traceback from dataclasses import dataclass, replace from multiprocessing import cpu_count, Pool from pathlib import Path from typing import Any, AnyStr, cast, Dict, List, Optional, Sequence, Union from libcst import parse_module, P...
Given an instantiated codemod and a string representing a module, transform that code by executing the transform, optionally invoking the formatter and finally printing any generated warnings to stderr. If the code includes the generated marker at any spot and ``include_generated`` is not set to ``True``, the code will...
4,955
import difflib import os.path import re import subprocess import sys import time import traceback from dataclasses import dataclass, replace from multiprocessing import cpu_count, Pool from pathlib import Path from typing import Any, AnyStr, cast, Dict, List, Optional, Sequence, Union from libcst import parse_module, P...
Given a list of files and an instantiated codemod we should apply to them, fork and apply the codemod in parallel to all of the files, including any configured formatter. The ``jobs`` parameter controls the maximum number of in-flight transforms, and needs to be at least 1. If not included, the number of jobs will auto...
4,956
from collections import defaultdict from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst from libcst import matchers as m, parse_statement from libcst._nodes.statement import Import, ImportFrom, SimpleStatementLine from libcst.codemod._context import CodemodContext from libcst.codemod._vis...
null
4,957
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst as cst import libcst.matchers as m from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer from libcst.codemod.v...
null
4,958
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst as cst import libcst.matchers as m from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer from libcst.codemod.v...
null
4,959
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst as cst import libcst.matchers as m from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer from libcst.codemod.v...
Given a series of import statements (both Import and ImportFrom), determine all of the names that have been imported into the current scope. For example: - ``import foo.bar as bar, foo.baz`` produces ``{'bar', 'foo.baz'}`` - ``from foo import (Bar, Baz as B)`` produces ``{'Bar', 'B'}`` - ``from foo import *`` produces ...
4,960
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst as cst import libcst.matchers as m from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer from libcst.codemod.v...
null
4,961
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst as cst import libcst.matchers as m from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer from libcst.codemod.v...
null
4,962
from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Set, Tuple, Union import libcst as cst import libcst.matchers as m from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer from libcst.codemod.v...
null
4,963
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union import libcst as cst from libcst.codemod._context import CodemodContext from libcst.codemod._visitor import ContextAwareTransformer, ContextAwareVisitor from libcst.codemod.visitors._gather_unused_imports import GatherUnusedImportsVisit...
null
4,964
import re from dataclasses import dataclass, fields from typing import Generator, List, Optional, Sequence, Set, Tuple, Type, Union import libcst as cst from libcst import ensure_type, parse_expression from libcst.codegen.gather import all_libcst_nodes, typeclasses class RemoveTypesFromGeneric(cst.CSTTransformer): ...
Given a BaseExpression from a type, return a new BaseExpression that does not refer to any types listed in values.
4,965
import re from dataclasses import dataclass, fields from typing import Generator, List, Optional, Sequence, Set, Tuple, Type, Union import libcst as cst from libcst import ensure_type, parse_expression from libcst.codegen.gather import all_libcst_nodes, typeclasses def _add_generic(name: str, oldtype: cst.BaseExpressi...
null
4,966
import re from dataclasses import dataclass, fields from typing import Generator, List, Optional, Sequence, Set, Tuple, Type, Union import libcst as cst from libcst import ensure_type, parse_expression from libcst.codegen.gather import all_libcst_nodes, typeclasses _global_aliases: Set[str] = set() class Field: nam...
Given a CSTNode, generate a field name and type string for each.
4,967
import inspect from collections import defaultdict from collections.abc import Sequence as ABCSequence from dataclasses import dataclass, fields, replace from typing import Dict, Iterator, List, Mapping, Sequence, Set, Type, Union import libcst as cst The provided code snippet includes necessary dependencies for imple...
Get all base classes that are subclasses of CSTNode but not an actual node itself. This allows us to keep our types sane by refering to the base classes themselves.
4,968
import inspect from collections import defaultdict from collections.abc import Sequence as ABCSequence from dataclasses import dataclass, fields, replace from typing import Dict, Iterator, List, Mapping, Sequence, Set, Type, Union import libcst as cst for node in all_libcst_nodes: # Map the base classes for this no...
Grab all CSTNodes that are not a superclass. Basically, anything that a person might use to generate a tree.
4,969
import inspect from collections import defaultdict from collections.abc import Sequence as ABCSequence from dataclasses import dataclass, fields, replace from typing import Dict, Iterator, List, Mapping, Sequence, Set, Type, Union import libcst as cst node_to_bases: Dict[Type[cst.CSTNode], List[Type[cst.CSTNode]]] = {}...
null
4,970
import inspect from collections import defaultdict from collections.abc import Sequence as ABCSequence from dataclasses import dataclass, fields, replace from typing import Dict, Iterator, List, Mapping, Sequence, Set, Type, Union import libcst as cst all_libcst_nodes: Sequence[Type[cst.CSTNode]] = sorted( _get_nod...
null
4,971
import argparse import os import os.path import shutil import subprocess import sys from typing import List import libcst as cst from libcst import ensure_type, parse_module from libcst.codegen.transforms import ( DoubleQuoteForwardRefsTransformer, SimplifyUnionsTransformer, ) def format_file(fname: str) -> Non...
null
4,972
import argparse import os import os.path import shutil import subprocess import sys from typing import List import libcst as cst from libcst import ensure_type, parse_module from libcst.codegen.transforms import ( DoubleQuoteForwardRefsTransformer, SimplifyUnionsTransformer, ) def format_file(fname: str) -> Non...
null
4,973
import argparse import os import os.path import shutil import subprocess import sys from typing import List import libcst as cst from libcst import ensure_type, parse_module from libcst.codegen.transforms import ( DoubleQuoteForwardRefsTransformer, SimplifyUnionsTransformer, ) def format_file(fname: str) -> Non...
null
4,974
import inspect import re from abc import ABC, abstractmethod from dataclasses import dataclass, field from typing import Optional, Pattern, Sequence, Union from libcst._add_slots import add_slots from libcst._maybe_sentinel import MaybeSentinel from libcst._nodes.base import CSTNode, CSTValidationError from libcst._nod...
Implementation Reference: - :func:`ast.get_docstring` https://docs.python.org/3/library/ast.html#ast.get_docstring and https://github.com/python/cpython/blob/89aa4694fc8c6d190325ef8ed6ce6a6b8efb3e50/Lib/ast.py#L254 - PEP 257 https://www.python.org/dev/peps/pep-0257/
4,975
from abc import ABC, abstractmethod from copy import deepcopy from dataclasses import dataclass, field, fields, replace from typing import Any, cast, ClassVar, Dict, List, Mapping, Sequence, TypeVar, Union from libcst._flatten_sentinel import FlattenSentinel from libcst._nodes.internal import CodegenState from libcst._...
null
4,976
from abc import ABC, abstractmethod from copy import deepcopy from dataclasses import dataclass, field, fields, replace from typing import Any, cast, ClassVar, Dict, List, Mapping, Sequence, TypeVar, Union from libcst._flatten_sentinel import FlattenSentinel from libcst._nodes.internal import CodegenState from libcst._...
null
4,977
from contextlib import contextmanager from dataclasses import dataclass, field from typing import Iterable, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union from libcst._add_slots import add_slots from libcst._flatten_sentinel import FlattenSentinel from libcst._maybe_sentinel import MaybeSentinel from libcst._...
Given a node, visits the node using `visitor`. If removal is attempted by the visitor, an exception is raised.
4,978
from contextlib import contextmanager from dataclasses import dataclass, field from typing import Iterable, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union from libcst._add_slots import add_slots from libcst._flatten_sentinel import FlattenSentinel from libcst._maybe_sentinel import MaybeSentinel from libcst._...
Given an optional node, visits the node if it exists with `visitor`. If the node is removed, returns None.
4,979
from contextlib import contextmanager from dataclasses import dataclass, field from typing import Iterable, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union from libcst._add_slots import add_slots from libcst._flatten_sentinel import FlattenSentinel from libcst._maybe_sentinel import MaybeSentinel from libcst._...
Given a node that can be a real value or a sentinel value, visits the node if it is real with `visitor`. If the node is removed, returns MaybeSentinel.