id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
6,068,501 | get_mypy_type_of_runtime_value | def get_mypy_type_of_runtime_value(runtime: Any) -> mypy.types.Type | None:
"""Returns a mypy type object representing the type of ``runtime``.
Returns None if we can't find something that works.
"""
if runtime is None:
return mypy.types.NoneType()
if isinstance(runtime, property):
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,291 | 1,384 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,502 | anytype | def anytype() -> mypy.types.AnyType:
return mypy.types.AnyType(mypy.types.TypeOfAny.unannotated) | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,303 | 1,304 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,503 | build_stubs | def build_stubs(modules: list[str], options: Options, find_submodules: bool = False) -> list[str]:
"""Uses mypy to construct stub objects for the given modules.
This sets global state that ``get_stub`` can access.
Returns all modules we might want to check. If ``find_submodules`` is False, this is equal
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,395 | 1,451 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,504 | get_stub | def get_stub(module: str) -> nodes.MypyFile | None:
"""Returns a stub object for the given module, if we've built one."""
return _all_stubs.get(module) | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,454 | 1,456 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,505 | get_typeshed_stdlib_modules | def get_typeshed_stdlib_modules(
custom_typeshed_dir: str | None, version_info: tuple[int, int] | None = None
) -> list[str]:
"""Returns a list of stdlib modules in typeshed (for current Python version)."""
stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
if version_in... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,459 | 1,493 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,506 | exists_in_version | def exists_in_version(module: str) -> bool:
assert version_info is not None
parts = module.split(".")
for i in range(len(parts), 0, -1):
current_module = ".".join(parts[:i])
if current_module in stdlib_py_versions:
minver, maxver = stdlib_py_versions[curre... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,470 | 1,478 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,507 | get_allowlist_entries | def get_allowlist_entries(allowlist_file: str) -> Iterator[str]:
def strip_comments(s: str) -> str:
try:
return s[: s.index("#")].strip()
except ValueError:
return s.strip()
with open(allowlist_file) as f:
for line in f.readlines():
entry = strip_comm... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,496 | 1,507 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,508 | strip_comments | def strip_comments(s: str) -> str:
try:
return s[: s.index("#")].strip()
except ValueError:
return s.strip() | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,497 | 1,501 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,509 | test_stubs | def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int:
"""This is stubtest! It's time to test the stubs!"""
# Load the allowlist. This is a series of strings corresponding to Error.object_desc
# Values in the dict will store whether we used the allowlist entry or not.
allowlist = ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,524 | 1,642 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,510 | set_strict_flags | def set_strict_flags() -> None: # not needed yet
return | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,565 | 1,566 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,511 | parse_options | def parse_options(args: list[str]) -> _Arguments:
parser = argparse.ArgumentParser(
description="Compares stubs to objects introspected from the runtime."
)
parser.add_argument("modules", nargs="*", help="Modules to test")
parser.add_argument(
"--concise",
action="store_true",
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,645 | 1,704 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,512 | main | def main() -> int:
mypy.util.check_python_version("stubtest")
return test_stubs(parse_options(sys.argv[1:])) | python | python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py | 1,707 | 1,709 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,513 | __init__ | def __init__(self, prog: str) -> None:
super().__init__(prog=prog, max_help_position=30) | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 30 | 31 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,514 | main | def main(argv: list[str]) -> None:
"""The code is top-down."""
check_python_version("dmypy")
args = parser.parse_args(argv)
if not args.action:
parser.print_usage()
else:
try:
args.action(args)
except BadStatus as err:
fail(err.args[0])
except ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 266 | 281 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,515 | fail | def fail(msg: str) -> NoReturn:
print(msg, file=sys.stderr)
sys.exit(2) | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 284 | 286 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,516 | action | def action(subparser: argparse.ArgumentParser) -> Callable[[ActionFunction], ActionFunction]:
"""Decorator to tie an action function to a subparser."""
def register(func: ActionFunction) -> ActionFunction:
subparser.set_defaults(action=func)
return func
return register | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 292 | 299 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,517 | register | def register(func: ActionFunction) -> ActionFunction:
subparser.set_defaults(action=func)
return func | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 295 | 297 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,518 | do_start | def do_start(args: argparse.Namespace) -> None:
"""Start daemon (it must not already be running).
This is where mypy flags are set from the command line.
Setting flags is a bit awkward; you have to use e.g.:
dmypy start -- --strict
since we don't want to duplicate mypy's huge list of flags.
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 306 | 324 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,519 | do_restart | def do_restart(args: argparse.Namespace) -> None:
"""Restart daemon (it may or may not be running; but not hanging).
We first try to stop it politely if it's running. This also sets
mypy flags from the command line (see do_start()).
"""
restart_server(args) | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 328 | 334 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,520 | restart_server | def restart_server(args: argparse.Namespace, allow_sources: bool = False) -> None:
"""Restart daemon (it may or may not be running; but not hanging)."""
try:
do_stop(args)
except BadStatus:
# Bad or missing status file or dead process; good to start.
pass
start_server(args, allow... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 337 | 344 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,521 | start_server | def start_server(args: argparse.Namespace, allow_sources: bool = False) -> None:
"""Start the server from command arguments and wait for it."""
# Lazy import so this import doesn't slow down other commands.
from mypy.dmypy_server import daemonize, process_start_options
start_options = process_start_opt... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 347 | 355 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,522 | wait_for_server | def wait_for_server(status_file: str, timeout: float = 5.0) -> None:
"""Wait until the server is up.
Exit if it doesn't happen within the timeout.
"""
endtime = time.time() + timeout
while time.time() < endtime:
try:
data = read_status(status_file)
except BadStatus:
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 358 | 375 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,523 | do_run | def do_run(args: argparse.Namespace) -> None:
"""Do a check, starting (or restarting) the daemon as necessary
Restarts the daemon if the running daemon reports that it is
required (due to a configuration change, for example).
Setting flags is a bit awkward; you have to use e.g.:
dmypy run -- --... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 379 | 417 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,524 | do_status | def do_status(args: argparse.Namespace) -> None:
"""Print daemon status.
This verifies that it is responsive to requests.
"""
status = read_status(args.status_file)
if args.verbose:
show_stats(status)
# Both check_status() and request() may raise BadStatus,
# which will be handled b... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 421 | 439 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,525 | do_stop | def do_stop(args: argparse.Namespace) -> None:
"""Stop daemon via a 'stop' request."""
# May raise BadStatus, which will be handled by main().
response = request(args.status_file, "stop", timeout=5)
if "error" in response:
show_stats(response)
fail(f"Daemon is stuck; consider {sys.argv[0... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 443 | 451 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,526 | do_kill | def do_kill(args: argparse.Namespace) -> None:
"""Kill daemon process with SIGKILL."""
pid, _ = get_status(args.status_file)
try:
kill(pid)
except OSError as err:
fail(str(err))
else:
print("Daemon killed") | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 455 | 463 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,527 | do_check | def do_check(args: argparse.Namespace) -> None:
"""Ask the daemon to check a list of files."""
t0 = time.time()
response = request(args.status_file, "check", files=args.files, export_types=args.export_types)
t1 = time.time()
response["roundtrip_time"] = t1 - t0
check_output(response, args.verbos... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 467 | 473 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,528 | do_recheck | def do_recheck(args: argparse.Namespace) -> None:
"""Ask the daemon to recheck the previous list of files, with optional modifications.
If at least one of --remove or --update is given, the server will
update the list of files to check accordingly and assume that any other files
are unchanged. If none... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 477 | 504 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,529 | do_suggest | def do_suggest(args: argparse.Namespace) -> None:
"""Ask the daemon for a suggested signature.
This just prints whatever the daemon reports as output.
For now it may be closer to a list of call sites.
"""
response = request(
args.status_file,
"suggest",
function=args.functio... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 508 | 526 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,530 | do_inspect | def do_inspect(args: argparse.Namespace) -> None:
"""Ask daemon to print the type of an expression."""
response = request(
args.status_file,
"inspect",
show=args.show,
location=args.location,
verbosity=args.verbose,
limit=args.limit,
include_span=args.incl... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 530 | 545 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,531 | check_output | def check_output(
response: dict[str, Any], verbose: bool, junit_xml: str | None, perf_stats_file: str | None
) -> None:
"""Print the output from a check or recheck command.
Call sys.exit() unless the status code is zero.
"""
if "error" in response:
fail(response["error"])
try:
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 548 | 585 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,532 | show_stats | def show_stats(response: Mapping[str, object]) -> None:
for key, value in sorted(response.items()):
if key not in ("out", "err"):
print("%-24s: %10s" % (key, "%.3f" % value if isinstance(value, float) else value))
else:
value = repr(value)[1:-1]
if len(value) > 50... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 588 | 596 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,533 | do_hang | def do_hang(args: argparse.Namespace) -> None:
"""Hang for 100 seconds, as a debug hack."""
print(request(args.status_file, "hang", timeout=1)) | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 600 | 602 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,534 | do_daemon | def do_daemon(args: argparse.Namespace) -> None:
"""Serve requests in the foreground."""
# Lazy import so this import doesn't slow down other commands.
from mypy.dmypy_server import Server, process_start_options
if args.options_data:
from mypy.options import Options
options_dict, timeo... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 606 | 625 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,535 | do_help | def do_help(args: argparse.Namespace) -> None:
"""Print full help (same as dmypy --help)."""
parser.print_help() | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 629 | 631 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,536 | request | def request(
status_file: str, command: str, *, timeout: int | None = None, **kwds: object
) -> dict[str, Any]:
"""Send a request to the daemon.
Return the JSON dict with the response.
Raise BadStatus if there is something wrong with the status file
or if the process whose pid is in the status fil... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 637 | 668 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,537 | get_status | def get_status(status_file: str) -> tuple[int, str]:
"""Read status file and check if the process is alive.
Return (pid, connection_name) on success.
Raise BadStatus if something's wrong.
"""
data = read_status(status_file)
return check_status(data) | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 671 | 679 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,538 | check_status | def check_status(data: dict[str, Any]) -> tuple[int, str]:
"""Check if the process is alive.
Return (pid, connection_name) on success.
Raise BadStatus if something's wrong.
"""
if "pid" not in data:
raise BadStatus("Invalid status file (no pid field)")
pid = data["pid"]
if not isin... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 682 | 701 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,539 | read_status | def read_status(status_file: str) -> dict[str, object]:
"""Read status file.
Raise BadStatus if the status file doesn't exist or contains
invalid JSON or the JSON is not a dict.
"""
if not os.path.isfile(status_file):
raise BadStatus("No status file found")
with open(status_file) as f:
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 704 | 719 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,540 | is_running | def is_running(status_file: str) -> bool:
"""Check if the server is running cleanly"""
try:
get_status(status_file)
except BadStatus:
return False
return True | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 722 | 728 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,541 | console_entry | def console_entry() -> None:
main(sys.argv[1:]) | python | python-3.10.8.amd64/Lib/site-packages/mypy/dmypy/client.py | 732 | 733 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,542 | get_singledispatch_info | def get_singledispatch_info(typ: Instance) -> SingledispatchTypeVars | None:
if len(typ.args) == 2:
return SingledispatchTypeVars(*typ.args) # type: ignore
return None | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 41 | 44 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,543 | get_first_arg | def get_first_arg(args: list[list[T]]) -> T | None:
"""Get the element that corresponds to the first argument passed to the function"""
if args and args[0]:
return args[0][0]
return None | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 50 | 54 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,544 | make_fake_register_class_instance | def make_fake_register_class_instance(
api: CheckerPluginInterface, type_args: Sequence[Type]
) -> Instance:
defn = ClassDef(REGISTER_RETURN_CLASS, Block([]))
defn.fullname = f"functools.{REGISTER_RETURN_CLASS}"
info = TypeInfo(SymbolTable(), defn, "functools")
obj_type = api.named_generic_type("bui... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 62 | 76 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,545 | fail | def fail(ctx: PluginContext, msg: str, context: Context | None) -> None:
"""Emit an error message.
This tries to emit an error message at the location specified by `context`, falling back to the
location specified by `ctx.context`. This is helpful when the only context information about
where you want ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 82 | 95 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,546 | create_singledispatch_function_callback | def create_singledispatch_function_callback(ctx: FunctionContext) -> Type:
"""Called for functools.singledispatch"""
func_type = get_proper_type(get_first_arg(ctx.arg_types))
if isinstance(func_type, CallableType):
if len(func_type.arg_kinds) < 1:
fail(
ctx, "Singledispa... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 98 | 123 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,547 | singledispatch_register_callback | def singledispatch_register_callback(ctx: MethodContext) -> Type:
"""Called for functools._SingleDispatchCallable.register"""
assert isinstance(ctx.type, Instance)
# TODO: check that there's only one argument
first_arg_type = get_proper_type(get_first_arg(ctx.arg_types))
if isinstance(first_arg_type... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 126 | 154 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,548 | register_function | def register_function(
ctx: PluginContext, singledispatch_obj: Instance, func: Type, register_arg: Type | None = None
) -> None:
"""Register a function"""
func = get_proper_type(func)
if not isinstance(func, CallableType):
return
metadata = get_singledispatch_info(singledispatch_obj)
if... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 157 | 188 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,549 | get_dispatch_type | def get_dispatch_type(func: CallableType, register_arg: Type | None) -> Type | None:
if register_arg is not None:
return register_arg
if func.arg_types:
return func.arg_types[0]
return None | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 191 | 196 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,550 | call_singledispatch_function_after_register_argument | def call_singledispatch_function_after_register_argument(ctx: MethodContext) -> Type:
"""Called on the function after passing a type to register"""
register_callable = ctx.type
if isinstance(register_callable, Instance):
type_args = RegisterCallableInfo(*register_callable.args) # type: ignore
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 199 | 209 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,551 | call_singledispatch_function_callback | def call_singledispatch_function_callback(ctx: MethodSigContext) -> FunctionLike:
"""Called for functools._SingleDispatchCallable.__call__"""
if not isinstance(ctx.type, Instance):
return ctx.default_signature
metadata = get_singledispatch_info(ctx.type)
if metadata is None:
return ctx.d... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/singledispatch.py | 212 | 219 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,552 | enum_name_callback | def enum_name_callback(ctx: mypy.plugin.AttributeContext) -> Type:
"""This plugin refines the 'name' attribute in enums to act as if
they were declared to be final.
For example, the expression 'MyEnum.FOO.name' normally is inferred
to be of type 'str'.
This plugin will instead make the inferred ty... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/enums.py | 33 | 54 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,553 | _first | def _first(it: Iterable[_T]) -> _T | None:
"""Return the first value from any iterable.
Returns ``None`` if the iterable is empty.
"""
for val in it:
return val
return None | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/enums.py | 60 | 67 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,554 | _infer_value_type_with_auto_fallback | def _infer_value_type_with_auto_fallback(
ctx: mypy.plugin.AttributeContext, proper_type: ProperType | None
) -> Type | None:
"""Figure out the type of an enum value accounting for `auto()`.
This method is a no-op for a `None` proper_type and also in the case where
the type is not "enum.auto"
"""
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/enums.py | 70 | 102 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,555 | _implements_new | def _implements_new(info: TypeInfo) -> bool:
"""Check whether __new__ comes from enum.Enum or was implemented in a
subclass. In the latter case, we must infer Any as long as mypy can't infer
the type of _value_ from assignments in __new__.
"""
type_with_new = _first(
ti
for ti in inf... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/enums.py | 105 | 117 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,556 | enum_value_callback | def enum_value_callback(ctx: mypy.plugin.AttributeContext) -> Type:
"""This plugin refines the 'value' attribute in enums to refer to
the original underlying value. For example, suppose we have the
following:
class SomeEnum:
FOO = A()
BAR = B()
By default, mypy will inf... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/enums.py | 120 | 229 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,557 | _extract_underlying_field_name | def _extract_underlying_field_name(typ: Type) -> str | None:
"""If the given type corresponds to some Enum instance, returns the
original name of that enum. For example, if we receive in the type
corresponding to 'SomeEnum.FOO', we return the string "SomeEnum.Foo".
This helper takes advantage of the fa... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/enums.py | 232 | 258 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,558 | functools_total_ordering_maker_callback | def functools_total_ordering_maker_callback(
ctx: mypy.plugin.ClassDefContext, auto_attribs_default: bool = False
) -> bool:
"""Add dunder methods to classes decorated with functools.total_ordering."""
comparison_methods = _analyze_class(ctx)
if not comparison_methods:
ctx.api.fail(
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/functools.py | 22 | 58 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,559 | _find_other_type | def _find_other_type(method: _MethodInfo) -> Type:
"""Find the type of the ``other`` argument in a comparison method."""
first_arg_pos = 0 if method.is_static else 1
cur_pos_arg = 0
other_arg = None
for arg_kind, arg_type in zip(method.type.arg_kinds, method.type.arg_types):
if arg_kind.is_p... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/functools.py | 61 | 80 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,560 | _analyze_class | def _analyze_class(ctx: mypy.plugin.ClassDefContext) -> dict[str, _MethodInfo | None]:
"""Analyze the class body, its parents, and return the comparison methods found."""
# Traverse the MRO and collect ordering methods.
comparison_methods: dict[str, _MethodInfo | None] = {}
# Skip object because total_o... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/functools.py | 83 | 104 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,561 | get_function_hook | def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None:
from mypy.plugins import ctypes, singledispatch
if fullname in ("contextlib.contextmanager", "contextlib.asynccontextmanager"):
return contextmanager_callback
elif fullname == "ctypes.Array":
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 39 | 48 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,562 | get_method_signature_hook | def get_method_signature_hook(
self, fullname: str
) -> Callable[[MethodSigContext], FunctionLike] | None:
from mypy.plugins import ctypes, singledispatch
if fullname == "typing.Mapping.get":
return typed_dict_get_signature_callback
elif fullname in {n + ".setdefault" fo... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 50 | 67 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,563 | get_method_hook | def get_method_hook(self, fullname: str) -> Callable[[MethodContext], Type] | None:
from mypy.plugins import ctypes, singledispatch
if fullname == "typing.Mapping.get":
return typed_dict_get_callback
elif fullname == "builtins.int.__pow__":
return int_pow_callback
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 69 | 94 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,564 | get_attribute_hook | def get_attribute_hook(self, fullname: str) -> Callable[[AttributeContext], Type] | None:
from mypy.plugins import ctypes, enums
if fullname == "ctypes.Array.value":
return ctypes.array_value_callback
elif fullname == "ctypes.Array.raw":
return ctypes.array_raw_callback
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 96 | 107 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,565 | get_class_decorator_hook | def get_class_decorator_hook(self, fullname: str) -> Callable[[ClassDefContext], None] | None:
from mypy.plugins import attrs, dataclasses
# These dataclass and attrs hooks run in the main semantic analysis pass
# and only tag known dataclasses/attrs classes, so that the second
# hooks ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 109 | 126 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,566 | get_class_decorator_hook_2 | def get_class_decorator_hook_2(
self, fullname: str
) -> Callable[[ClassDefContext], bool] | None:
from mypy.plugins import attrs, dataclasses, functools
if fullname in dataclasses.dataclass_makers:
return dataclasses.dataclass_class_maker_callback
elif fullname in funct... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 128 | 148 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,567 | contextmanager_callback | def contextmanager_callback(ctx: FunctionContext) -> Type:
"""Infer a better return type for 'contextlib.contextmanager'."""
# Be defensive, just in case.
if ctx.arg_types and len(ctx.arg_types[0]) == 1:
arg_type = get_proper_type(ctx.arg_types[0][0])
default_return = get_proper_type(ctx.def... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 151 | 167 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,568 | typed_dict_get_signature_callback | def typed_dict_get_signature_callback(ctx: MethodSigContext) -> CallableType:
"""Try to infer a better signature type for TypedDict.get.
This is used to get better type context for the second argument that
depends on a TypedDict value type.
"""
signature = ctx.default_signature
if (
isi... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 170 | 207 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,569 | typed_dict_get_callback | def typed_dict_get_callback(ctx: MethodContext) -> Type:
"""Infer a precise return type for TypedDict.get with literal first argument."""
if (
isinstance(ctx.type, TypedDictType)
and len(ctx.arg_types) >= 1
and len(ctx.arg_types[0]) == 1
):
keys = try_getting_str_literals(ctx... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 210 | 246 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,570 | typed_dict_pop_signature_callback | def typed_dict_pop_signature_callback(ctx: MethodSigContext) -> CallableType:
"""Try to infer a better signature type for TypedDict.pop.
This is used to get better type context for the second argument that
depends on a TypedDict value type.
"""
signature = ctx.default_signature
str_type = ctx.a... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 249 | 276 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,571 | typed_dict_pop_callback | def typed_dict_pop_callback(ctx: MethodContext) -> Type:
"""Type check and infer a precise return type for TypedDict.pop."""
if (
isinstance(ctx.type, TypedDictType)
and len(ctx.arg_types) >= 1
and len(ctx.arg_types[0]) == 1
):
keys = try_getting_str_literals(ctx.args[0][0], ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 279 | 307 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,572 | typed_dict_setdefault_signature_callback | def typed_dict_setdefault_signature_callback(ctx: MethodSigContext) -> CallableType:
"""Try to infer a better signature type for TypedDict.setdefault.
This is used to get better type context for the second argument that
depends on a TypedDict value type.
"""
signature = ctx.default_signature
st... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 310 | 330 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,573 | typed_dict_setdefault_callback | def typed_dict_setdefault_callback(ctx: MethodContext) -> Type:
"""Type check TypedDict.setdefault and infer a precise return type."""
if (
isinstance(ctx.type, TypedDictType)
and len(ctx.arg_types) == 2
and len(ctx.arg_types[0]) == 1
and len(ctx.arg_types[1]) == 1
):
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 333 | 369 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,574 | typed_dict_delitem_callback | def typed_dict_delitem_callback(ctx: MethodContext) -> Type:
"""Type check TypedDict.__delitem__."""
if (
isinstance(ctx.type, TypedDictType)
and len(ctx.arg_types) == 1
and len(ctx.arg_types[0]) == 1
):
keys = try_getting_str_literals(ctx.args[0][0], ctx.arg_types[0][0])
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 372 | 389 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,575 | typed_dict_update_signature_callback | def typed_dict_update_signature_callback(ctx: MethodSigContext) -> CallableType:
"""Try to infer a better signature type for TypedDict.update."""
signature = ctx.default_signature
if isinstance(ctx.type, TypedDictType) and len(signature.arg_types) == 1:
arg_type = get_proper_type(signature.arg_types... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 392 | 401 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,576 | int_pow_callback | def int_pow_callback(ctx: MethodContext) -> Type:
"""Infer a more precise return type for int.__pow__."""
# int.__pow__ has an optional modulo argument,
# so we expect 2 argument positions
if len(ctx.arg_types) == 2 and len(ctx.arg_types[0]) == 1 and len(ctx.arg_types[1]) == 0:
arg = ctx.args[0]... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 404 | 421 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,577 | int_neg_callback | def int_neg_callback(ctx: MethodContext) -> Type:
"""Infer a more precise return type for int.__neg__.
This is mainly used to infer the return type as LiteralType
if the original underlying object is a LiteralType object
"""
if isinstance(ctx.type, Instance) and ctx.type.last_known_value is not Non... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 424 | 447 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,578 | tuple_mul_callback | def tuple_mul_callback(ctx: MethodContext) -> Type:
"""Infer a more precise return type for tuple.__mul__ and tuple.__rmul__.
This is used to return a specific sized tuple if multiplied by Literal int
"""
if not isinstance(ctx.type, TupleType):
return ctx.default_return_type
arg_type = get... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/default.py | 450 | 468 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,579 | _get_decorator_bool_argument | def _get_decorator_bool_argument(ctx: ClassDefContext, name: str, default: bool) -> bool:
"""Return the bool argument for the decorator.
This handles both @decorator(...) and @decorator.
"""
if isinstance(ctx.reason, CallExpr):
return _get_bool_argument(ctx, ctx.reason, name, default)
else:... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 37 | 45 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,580 | _get_bool_argument | def _get_bool_argument(ctx: ClassDefContext, expr: CallExpr, name: str, default: bool) -> bool:
"""Return the boolean value for an argument to a call or the
default if it's not found.
"""
attr_value = _get_argument(expr, name)
if attr_value:
ret = ctx.api.parse_bool(attr_value)
if re... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 48 | 59 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,581 | _get_argument | def _get_argument(call: CallExpr, name: str) -> Expression | None:
"""Return the expression for the specific argument."""
# To do this we use the CallableType of the callee to find the FormalArgument,
# then walk the actual CallExpr looking for the appropriate argument.
#
# Note: I'm not hard-coding... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 62 | 95 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,582 | add_method | def add_method(
ctx: ClassDefContext,
name: str,
args: list[Argument],
return_type: Type,
self_type: Type | None = None,
tvar_def: TypeVarType | None = None,
) -> None:
"""
Adds a new method to a class.
Deprecated, use add_method_to_class() instead.
"""
add_method_to_class(
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 98 | 118 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,583 | add_method_to_class | def add_method_to_class(
api: SemanticAnalyzerPluginInterface | CheckerPluginInterface,
cls: ClassDef,
name: str,
args: list[Argument],
return_type: Type,
self_type: Type | None = None,
tvar_def: TypeVarType | None = None,
) -> None:
"""Adds a new method to a class definition."""
inf... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 121 | 172 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,584 | add_attribute_to_class | def add_attribute_to_class(
api: SemanticAnalyzerPluginInterface,
cls: ClassDef,
name: str,
typ: Type,
final: bool = False,
no_serialize: bool = False,
override_allow_incompatible: bool = False,
) -> None:
"""
Adds a new attribute to a class definition.
This currently only genera... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 175 | 207 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,585 | deserialize_and_fixup_type | def deserialize_and_fixup_type(data: str | JsonDict, api: SemanticAnalyzerPluginInterface) -> Type:
typ = deserialize_type(data)
typ.accept(TypeFixer(api.modules, allow_missing=False))
return typ | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/common.py | 210 | 213 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,586 | __init__ | def __init__(
self,
name: str,
is_in_init: bool,
is_init_var: bool,
has_default: bool,
line: int,
column: int,
type: Type | None,
info: TypeInfo,
kw_only: bool,
) -> None:
self.name = name
self.is_in_init = is_in_init
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 64 | 84 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,587 | to_argument | def to_argument(self) -> Argument:
arg_kind = ARG_POS
if self.kw_only and self.has_default:
arg_kind = ARG_NAMED_OPT
elif self.kw_only and not self.has_default:
arg_kind = ARG_NAMED
elif not self.kw_only and self.has_default:
arg_kind = ARG_OPT
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 86 | 96 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,588 | to_var | def to_var(self) -> Var:
return Var(self.name, self.type) | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 98 | 99 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,589 | serialize | def serialize(self) -> JsonDict:
assert self.type
return {
"name": self.name,
"is_in_init": self.is_in_init,
"is_init_var": self.is_init_var,
"has_default": self.has_default,
"line": self.line,
"column": self.column,
"ty... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 101 | 112 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,590 | deserialize | def deserialize(
cls, info: TypeInfo, data: JsonDict, api: SemanticAnalyzerPluginInterface
) -> DataclassAttribute:
data = data.copy()
if data.get("kw_only") is None:
data["kw_only"] = False
typ = deserialize_and_fixup_type(data.pop("type"), api)
return cls(type=t... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 115 | 122 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,591 | expand_typevar_from_subtype | def expand_typevar_from_subtype(self, sub_type: TypeInfo) -> None:
"""Expands type vars in the context of a subtype when an attribute is inherited
from a generic super type."""
if self.type is not None:
self.type = map_type_from_supertype(self.type, sub_type, self.info) | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 124 | 128 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,592 | __init__ | def __init__(self, ctx: ClassDefContext) -> None:
self._ctx = ctx | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 141 | 142 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,593 | transform | def transform(self) -> bool:
"""Apply all the necessary transformations to the underlying
dataclass so as to ensure it is fully type checked according
to the rules in PEP 557.
"""
ctx = self._ctx
info = self._ctx.cls.info
attributes = self.collect_attributes()
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 144 | 280 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,594 | add_slots | def add_slots(
self, info: TypeInfo, attributes: list[DataclassAttribute], *, correct_version: bool
) -> None:
if not correct_version:
# This means that version is lower than `3.10`,
# it is just a non-existent argument for `dataclass` function.
self._ctx.api.fail... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 282 | 311 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,595 | reset_init_only_vars | def reset_init_only_vars(self, info: TypeInfo, attributes: list[DataclassAttribute]) -> None:
"""Remove init-only vars from the class and reset init var declarations."""
for attr in attributes:
if attr.is_init_var:
if attr.name in info.names:
del info.name... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 313 | 328 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,596 | collect_attributes | def collect_attributes(self) -> list[DataclassAttribute] | None:
"""Collect all attributes declared in the dataclass and its parents.
All assignments of the form
a: SomeType
b: SomeOtherType = ...
are collected.
Return None if some dataclass base class hasn't been... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 330 | 507 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,597 | _freeze | def _freeze(self, attributes: list[DataclassAttribute]) -> None:
"""Converts all attributes to @property methods in order to
emulate frozen classes.
"""
info = self._ctx.cls.info
for attr in attributes:
sym_node = info.names.get(attr.name)
if sym_node is n... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 509 | 525 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,598 | _propertize_callables | def _propertize_callables(
self, attributes: list[DataclassAttribute], settable: bool = True
) -> None:
"""Converts all attributes with callable types to @property methods.
This avoids the typechecker getting confused and thinking that
`my_dataclass_instance.callable_attr(foo)` is g... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 527 | 545 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,599 | _is_kw_only_type | def _is_kw_only_type(self, node: Type | None) -> bool:
"""Checks if the type of the node is the KW_ONLY sentinel value."""
if node is None:
return False
node_type = get_proper_type(node)
if not isinstance(node_type, Instance):
return False
return node_type... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 547 | 554 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,068,600 | _add_dataclass_fields_magic_attribute | def _add_dataclass_fields_magic_attribute(self) -> None:
attr_name = "__dataclass_fields__"
any_type = AnyType(TypeOfAny.explicit)
field_type = self._ctx.api.named_type_or_none("dataclasses.Field", [any_type]) or any_type
attr_type = self._ctx.api.named_type(
"builtins.dict",... | python | python-3.10.8.amd64/Lib/site-packages/mypy/plugins/dataclasses.py | 556 | 568 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.