repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
textual | docs/examples/styles/background_tint.py | .py | from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Label
class BackgroundTintApp(App):
CSS_PATH = "background_tint.tcss"
def compose(self) -> ComposeResult:
with Vertical(id="tint1"):
yield Label("0%")
with Vertical(id="t... | 25 | 631 |
clearml | clearml/binding/hydra_bind.py | .py | import io
import sys
from functools import partial
from typing import Callable, List, TYPE_CHECKING, Any
if TYPE_CHECKING:
from omegaconf import omegaconf
from ..config import running_remotely, get_remote_task_id, DEV_TASK_NO_REUSE
from ..debugging.log import LoggerRoot
class PatchHydra:
_original_run_job =... | 291 | 12,540 |
probability | tensorflow_probability/python/distributions/wishart_test.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 553 | 21,728 |
openvino | src/frontends/onnx/tests/tests_python/test_backend.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import logging
import onnx.backend.test
from tests import (
BACKEND_NAME,
skip_rng_tests,
xfail_issue_33488,
xfail_issue_33596,
xfail_issue_33606,
xfail_issue_33651,
xf... | 887 | 47,552 |
metrics | src/torchmetrics/functional/segmentation/__init__.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 20 | 972 |
saleor | saleor/graphql/translations/mutations/product_bulk_translate.py | .py | import graphene
from django.core.exceptions import ValidationError
from graphql.error import GraphQLError
from ....permission.enums import SitePermissions
from ....product import models
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.enums import LanguageCodeEnum, ProductTranslateErrorCode
from ...... | 139 | 4,577 |
openvino | src/bindings/python/tests/test_graph/test_ops_unary.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset13 as ops
import openvino.opset17 as ops_opset17
from openvino import Shape, Type
R_TOLERANCE = 1e-6 # global relative tolerance
@pytest.mark.parametrize(... | 244 | 7,441 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_hierarchical_ortmodule.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from collections.abc import Iterable
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.checkpoint import checkpoint
from onnxruntime.training.ortmodule import ORTModule # noqa: F401
from o... | 249 | 6,872 |
pyomo | pyomo/version/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 21 | 946 |
onnx | onnx/reference/ops/op_gru.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class CommonGRU(OpRun):
def __init__(self, onnx_node, run_params):
OpRun.__init__(self, onnx_node, run_params)
self.n_out... | 188 | 5,444 |
sphinx | tests/test_writers/test_docutilsconf.py | .py | """Test docutils.conf support for several writers."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from docutils import nodes
from sphinx.testing.util import assert_node
from sphinx.util.docutils import patch_docutils
if TYPE_CHECKING:
from sphinx.application import Sphinx
... | 51 | 1,278 |
funcy | tests/test_calc.py | .py | from math import sin, cos
from datetime import timedelta
import pytest
from funcy.calc import *
def test_memoize():
@memoize
def inc(x):
calls.append(x)
return x + 1
calls = []
assert inc(0) == 1
assert inc(1) == 2
assert inc(0) == 1
assert calls == [0, 1]
# using kw... | 201 | 4,086 |
wandb | tests/unit_tests/test_wandb_agent_signals.py | .py | import os
import signal
import subprocess
from unittest import mock
import pytest
from wandb import wandb_agent
class _DummyPopen:
def __init__(self, *args, **kwargs):
self.stdin = mock.Mock()
self.sent = []
def send_signal(self, signum):
self.sent.append(signum)
def kill(self):... | 417 | 13,950 |
sqlmap | lib/request/httpshandler.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
import socket
from lib.core.common import filterNone
from lib.core.common import getSafeExString
from lib.core.compat import LooseVersion
from lib.core.compat import xr... | 154 | 6,505 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Resize.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
OPS = {
'tf.raw_ops.ResizeBilinear': tf.raw_ops.ResizeBilinear,
'tf.raw_ops.ResizeNearestNeighbor... | 70 | 3,608 |
luigi | luigi/contrib/__init__.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 20 | 661 |
hatch | tests/helpers/templates/licenses/__init__.py | .py | Apache_2_0 = """\
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution
as defined by Sections 1 through 9 of this document.
"Lice... | 212 | 11,379 |
sqlmap | lib/request/redirecthandler.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import io
import re
import time
import types
from lib.core.common import getHostHeader
from lib.core.common import getSafeExString
from lib.core.common import logHTTPTraffic
from... | 235 | 10,413 |
httpie | tests/test_update_warnings.py | .py | import json
import tempfile
import time
from contextlib import suppress
from datetime import datetime
from pathlib import Path
import pytest
from httpie.internal.daemon_runner import STATUS_FILE
from httpie.internal.daemons import spawn_daemon
from httpie.status import ExitStatus
from .utils import PersistentMockEnv... | 241 | 6,637 |
onnx | onnx/backend/test/report/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Any
import pytest
from onnx.backend.test.report.coverage import Coverage
if TYPE_CHECKING:
from collections.abc import Sequence
import _pytest
_coverage = C... | 51 | 1,321 |
saleor | saleor/graphql/app/dataloaders/__init__.py | .py | from .app import ActiveAppByIdLoader, AppByIdLoader, AppByTokenLoader
from .app_extension import AppExtensionByAppIdLoader, AppExtensionByIdLoader
from .app_problems import AppProblemsByAppIdLoader
from .app_tokens import AppTokensByAppIdLoader
from .apps import ActiveAppsByAppIdentifierLoader, AppsByEventTypeLoader
fr... | 27 | 925 |
voila | tests/app/prelaunch_hook_papermill_test.py | .py | # tests prelaunch hook config
import os
from urllib.parse import quote_plus
import pytest
BASE_DIR = os.path.dirname(__file__)
@pytest.fixture
def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, "print_parameterized.ipynb")
@pytest.fixture
def voila_config():
def parameterize_w... | 64 | 1,999 |
black | tests/data/cases/jupytext_markdown_fmt.py | .py | # Test that Jupytext markdown comments are preserved before fmt:off/on blocks
# %% [markdown]
# fmt: off
# fmt: on
# Also test with other comments
# Some comment
# %% [markdown]
# Another comment
# fmt: off
x = 1
# fmt: on
# Test multiple markdown comments
# %% [markdown]
# First markdown
# %% [code]
# Code cell
#... | 24 | 345 |
pyomo | pyomo/solvers/tests/piecewise_linear/test_piecewise_linear.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 203 | 7,518 |
onnx | onnx/reference/ops/aionnx_preview/op_flex_attention.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Any
import ml_dtypes
import numpy as np
from onnx import TensorProto
from onnx.reference.op_run import OpRun
if TYPE_CHECKING:
from collections.abc import Sequen... | 161 | 5,305 |
readthedocs.org | readthedocs/doc_builder/base.py | .py | """Base classes for Builders."""
import os
from functools import wraps
import structlog
log = structlog.get_logger(__name__)
def restoring_chdir(fn):
# XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
path = os.getcwd()
try:
return... | 65 | 1,857 |
saleor | saleor/core/middleware.py | .py | import datetime
import logging
from typing import TYPE_CHECKING, Union
from django.conf import settings
from .jwt import JWT_REFRESH_TOKEN_COOKIE_NAME, jwt_decode_with_exception_handler
if TYPE_CHECKING:
from ..account.models import User
from ..app.models import App
Requestor = Union["User", "App"]
logger ... | 42 | 1,363 |
kombu | examples/complete_receive.py | .py | """
Example of simple consumer that waits for a single message, acknowledges it
and exits.
"""
from __future__ import annotations
from pprint import pformat
from kombu import Connection, Consumer, Exchange, Queue, eventloop
#: By default messages sent to exchanges are persistent (delivery_mode=2),
#: and queues an... | 48 | 1,550 |
wandb | wandb/errors/errors.py | .py | from __future__ import annotations
class Error(Exception):
"""Base W&B Error."""
def __init__(self, message: str, context: dict | None = None) -> None:
super().__init__(message)
self.message = message
# sentry context capture
if context:
self.context = context
cl... | 38 | 931 |
hydra | tools/configen/tests/test_modules/future_annotations.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from __future__ import annotations # type: ignore # noqa: F407
from dataclasses import dataclass
from typing import List, Optional
from omegaconf import MISSING
@dataclass
class User:
name: str = MISSING
age: int = MISSING
class Libra... | 55 | 1,533 |
conda | tests/data/recipes/generate_recipes_readme.py | .py | #!/usr/bin/env python3
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Generate a test-recipes README from rendered package metadata.
This reads package metadata from artifacts in ``tests/data/test-recipes``:
- ``info/index.json`` for package name and version (source of truth)
- ``info/re... | 244 | 7,837 |
openvino | tests/layer_tests/pytorch_tests/test_elu.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import torch.nn.functional as F
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class aten_elu(torch.nn.Module):
def __init__(self, alpha, dtype, inplace):
super().__init__(... | 45 | 1,503 |
ipython | IPython/core/splitinput.py | .py | """
Simple utility for splitting user input. This is used by both inputsplitter and
prefilter.
"""
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
import re
import warnings
from typing import TYPE... | 157 | 5,048 |
clearml | clearml/backend_api/session/jsonmodels/models.py | .py | from typing import Tuple, Dict, Iterator, Any, Generator
from . import parsers, errors
from .fields import BaseField
from .errors import ValidationError
class JsonmodelMeta(type):
def __new__(cls, name: str, bases: Tuple[Any], attributes: Dict[str, Any]) -> "JsonmodelMeta":
cls.validate_fields(attributes... | 143 | 4,863 |
saleor | saleor/graphql/account/mutations/account/account_request_deletion.py | .py | from typing import cast
from urllib.parse import urlencode
import graphene
from django.core.exceptions import ValidationError
from .....account import notifications
from .....account.error_codes import AccountErrorCode
from .....account.models import User
from .....core.tokens import account_delete_token_generator
fr... | 91 | 3,280 |
pyomo | pyomo/contrib/latex_printer/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 18 | 837 |
cvxpy | cvxpy/reductions/solvers/conic_solvers/qoco_conif.py | .py | """
Copyright 2025, the CVXPY Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, sof... | 269 | 8,978 |
saleor | saleor/graphql/attribute/mutations/attribute_bulk_update.py | .py | from collections import defaultdict
from dataclasses import dataclass, field
import graphene
from django.core.exceptions import ValidationError
from django.db import transaction
from django.db.models import Q, prefetch_related_objects
from django.utils.text import slugify
from graphene.utils.str_converters import to_c... | 905 | 34,414 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_AdjustSaturation.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(2323534)
class TestAdjustSaturation(CommonTFLayerTest):
def _prepare_inp... | 55 | 2,562 |
django-cms | cms/utils/compat/__init__.py | .py | from platform import python_version
from django import get_version
from packaging.version import Version
DJANGO_VERSION = get_version()
PYTHON_VERSION = python_version()
# These mean "less than or equal to DJANGO_FOO_BAR"
# Kept for backward compatibility, none of them used currently
DJANGO_2_2 = Version(DJANGO_VERS... | 21 | 802 |
hatch | tests/env/plugin/test_interface.py | .py | import re
import pytest
from hatch.config.constants import AppEnvVars
from hatch.env.plugin.interface import EnvironmentInterface
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
class MockEnvironment(EnvironmentInterface): # no cov
PLUGIN_NAME = "mock"
def find(self):
... | 4,532 | 152,955 |
saleor | saleor/graphql/product/tests/benchmark/test_product_bulk_create.py | .py | import json
import graphene
import pytest
from .....attribute.models import Attribute
from .....product.models import Product
from ....tests.utils import get_graphql_content
PRODUCT_BULK_CREATE_MUTATION = """
mutation ProductBulkCreate(
$products: [ProductBulkCreateInput!]!
) {
productBulkCre... | 168 | 4,941 |
beam | sdks/python/apache_beam/examples/dataframe/taxiride_it_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 108 | 3,460 |
astropy | astropy/coordinates/tests/accuracy/generate_ref_ast.py | .py | # /// script
# requires-python = ">=3.10"
# dependencies = [
# "starlink-pyast>=4.0.0",
# "numpy",
# "astropy",
# ]
# ///
"""
This series of functions are used to generate the reference CSV files
used by the accuracy tests. Running this as a command-line script will
generate them all.
"""
from pathlib imp... | 278 | 9,787 |
astropy | astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py | .py | import warnings
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
import astropy.units as u
from astropy.coordinates import ICRS, Galactic, SkyCoord
from astropy.io.fits import Header
from astropy.io.fits.verify import VerifyWarning
from astropy.time import Time
from astropy.uni... | 1,050 | 33,912 |
pyomo | pyomo/contrib/solver/solvers/gurobi/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 12 | 790 |
lemur | docs/conf.py | .py | # -*- coding: utf-8 -*-
#
# lemur documentation build configuration file, created by
# sphinx-quickstart on Sat Jun 7 18:43:48 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All... | 282 | 9,254 |
loguru | tests/exceptions/source/diagnose/parenthesis.py | .py | # fmt: off
import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=True, backtrace=False, diagnose=True)
class XYZ:
pass
def a(b, c):
x = XYZ()
x.val = 9
(a, b, x.val, ) = 12, 15 / c, 17
def b():
foo, bar, baz = {}, XYZ, 0
foo[("baz")] = bar() + (a... | 48 | 626 |
coremltools | coremltools/converters/mil/experimental/passes/generic_conv_batchnorm_fusion.py | .py | # Copyright (c) 2021, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import os
import numpy as np
from coremltools.converters.mil import Builder as mb
from coremltools.... | 170 | 6,064 |
sqlmap | plugins/dbms/sybase/fingerprint.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.common import unArrayizeValue
from lib.core.compat import xrange
from lib.core.data import con... | 121 | 3,428 |
ipython | tests/test_capture.py | .py | # encoding: utf-8
"""Tests for IPython.utils.capture"""
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this softwa... | 181 | 5,597 |
saleor | saleor/graphql/payment/tests/queries/test_transactions.py | .py | import pytest
from .....order.models import Order
from ....tests.utils import assert_no_permission, get_graphql_content
@pytest.fixture
def transactions_in_different_channels(
order_list,
checkout,
channel_USD,
channel_JPY,
channel_PLN,
transaction_item_generator,
):
order_list[0].channel... | 243 | 7,092 |
wagtail | wagtail/management/commands/publish_scheduled.py | .py | import swapper
from django.apps import apps
from django.core.management.base import BaseCommand
from django.utils import dateparse, timezone
from wagtail.models import DraftStateMixin, Revision
Page = swapper.load_model("wagtailcore", "Page")
def revision_date_expired(r):
expiry_str = r.content.get("expire_at")... | 121 | 4,738 |
hydra | hydra/core/override_parser/types.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import decimal
import fnmatch
from copy import copy
from dataclasses import dataclass, field
from enum import Enum
from random import shuffle
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Union, cast
from omegaconf import O... | 498 | 15,901 |
pyomo | scripts/admin/contributors.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 245 | 9,553 |
mlflow | mlflow/mcp/server.py | .py | import contextlib
import io
import os
from typing import TYPE_CHECKING, Any, Callable
import click
from click.types import BOOL, FLOAT, INT, STRING, UUID
import mlflow.deployments.cli as deployments_cli
import mlflow.experiments
import mlflow.models.cli as models_cli
import mlflow.runs
from mlflow.ai_commands.ai_comm... | 256 | 8,485 |
luigi | test/numerical_parameter_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 98 | 4,234 |
wagtail | wagtail/models/orderable.py | .py | from django.db import models
class Orderable(models.Model):
sort_order = models.IntegerField(null=True, blank=True, editable=False)
sort_order_field = "sort_order"
class Meta:
abstract = True
ordering = ["sort_order"]
def set_max_order(instance, sort_order_field):
# Get the maximum ... | 21 | 630 |
python-prompt-toolkit | examples/prompts/patch-stdout.py | .py | #!/usr/bin/env python
"""
An example that demonstrates how `patch_stdout` works.
This makes sure that output from other threads doesn't disturb the rendering of
the prompt, but instead is printed nicely above the prompt.
"""
import threading
import time
from prompt_toolkit import prompt
from prompt_toolkit.patch_std... | 43 | 919 |
mlflow | mlflow/entities/run_data.py | .py | from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.entities.metric import Metric
from mlflow.entities.param import Param
from mlflow.entities.run_tag import RunTag
from mlflow.protos.service_pb2 import Param as ProtoParam
from mlflow.protos.service_pb2 import RunData as ProtoRunData
from mlflow.protos... | 85 | 3,039 |
textual | tests/tree/test_tree_availability.py | .py | from __future__ import annotations
from typing import Any
from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Tree
class TreeApp(App[None]):
"""Test tree app."""
def __init__(self, disabled: bool, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, ... | 129 | 4,240 |
attrs | src/attr/validators.py | .py | # SPDX-License-Identifier: MIT
"""
Commonly useful validators.
"""
import operator
import re
from contextlib import contextmanager
from re import Pattern
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .ex... | 767 | 21,903 |
saleor | saleor/graphql/payment/mutations/stored_payment_methods/payment_gateway_initialize_tokenization.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....payment.interface import PaymentGatewayInitializeTokenizationRequestData
from .....permission.auth_filters import AuthorizationFilters
from .....webhook.event_types import WebhookEventSyncType
from ....channel.utils import validate_channel
fr... | 112 | 4,260 |
saleor | saleor/tests/e2e/checkout/zero_total/test_0_total_checkout_line_voucher_and_click_and_collect.py | .py | import pytest
from ...channel.utils import update_channel
from ...product.utils.preparing_product import prepare_products
from ...shop.utils.preparing_shop import prepare_default_shop
from ...utils import assign_permissions
from ...vouchers.utils.prepare_voucher import prepare_voucher
from ...warehouse.utils import up... | 217 | 8,453 |
bazel | third_party/py/abseil/absl/flags/_exceptions.py | .py | # Copyright 2017 The Abseil Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | 109 | 3,657 |
openvino | src/bindings/python/src/openvino/opset5/ops.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
from typing import Optional, Union
import numpy as np
from functools import partial
from openvino import Node, Shape
from openvino.op import Constant, Parameter, loo... | 371 | 14,826 |
wagtail | wagtail/admin/forms/pages.py | .py | import swapper
from django import forms
from django.conf import settings
from django.utils.translation import gettext as _
from django.utils.translation import ngettext
from wagtail.admin import widgets
from wagtail.models import PageViewRestriction
from wagtail.permissions import policy_registry
from .models import ... | 324 | 12,557 |
textual | docs/examples/how-to/containers03.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder
class Box(Placeholder):
"""Example widget."""
DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""
class ContainerApp(App):
"""Simple app to pl... | 36 | 657 |
pyomo | pyomo/contrib/preprocessing/plugins/bounds_to_vars.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 154 | 5,891 |
pyomo | pyomo/contrib/mindtpy/feasibility_pump.py | .py | # -*- coding: utf-8 -*-
# ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and E... | 79 | 2,715 |
pyomo | pyomo/repn/plugins/parameterized_standard_form.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 359 | 14,202 |
pyro | pyro/contrib/mue/dataloaders.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import torch
from torch.utils.data import Dataset
alphabets = {
"amino-acid": np.array(
[
"R",
"H",
"K",
"D",
"E",
"S",
... | 198 | 6,063 |
saleor | saleor/product/tests/test_product_search.py | .py | from ..models import Product
from ..search import update_products_search_vector
def test_update_products_search_vector(product_list):
# given
for product in product_list:
product.search_vector = None
Product.objects.bulk_update(product_list, ["search_vector"])
# when
update_products_searc... | 18 | 497 |
mlflow | examples/strands/tracing.py | .py | import mlflow
mlflow.strands.autolog()
mlflow.set_experiment("Strand Agent")
from strands import Agent
from strands.models.openai import OpenAIModel
from strands_tools import calculator
model = OpenAIModel(
client_args={"api_key": "<api-key>"},
# **model_config
model_id="gpt-4o",
params={
"ma... | 23 | 470 |
scikit-bio | skbio/sequence/_sequence.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 2,415 | 79,738 |
textual | tests/snapshot_tests/snapshot_apps/masked_input.py | .py | from textual.app import App, ComposeResult
from textual.widgets import MaskedInput
class TemplateApp(App[None]):
def compose(self) -> ComposeResult:
yield MaskedInput(">NNNNN-NNNNN-NNNNN-NNNNN;_")
yield MaskedInput("9999-99-99", placeholder="YYYY-MM-DD")
if __name__ == "__main__":
app = Temp... | 13 | 343 |
pyomo | pyomo/core/base/reference.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 798 | 32,906 |
coveragepy | tests/test_oddball.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Oddball cases for testing coverage.py"""
from __future__ import annotations
import os.path
import re
import sys
import warnings
import pytest
import covera... | 786 | 26,950 |
onnxruntime | orttraining/orttraining/test/python/perf_log/ort_module_perf_test_tools.py | .py | # https://docs.microsoft.com/en-us/azure/mysql/connect-python
import argparse
import os
from datetime import datetime
import git
import mysql.connector
from mysql.connector import errorcode
def get_repo_commit(repo_path):
repo = git.Repo(repo_path, search_parent_directories=True)
sha = repo.head.object.hexs... | 222 | 7,647 |
pyomo | pyomo/contrib/simplification/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 11 | 580 |
confluent-kafka-python | src/confluent_kafka/_oauthbearer/aws/aws_iam_marker.py | .py | # Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 38 | 1,497 |
returns | returns/pointfree/lash.py | .py | from collections.abc import Callable
from typing import TypeVar
from returns.interfaces.lashable import LashableN
from returns.primitives.hkt import Kinded, KindN, kinded
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_ThirdType = TypeVar('_ThirdType')
_UpdatedType = TypeVar('_UpdatedType')
... | 62 | 1,765 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/Notebook with many hash signs.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% [markdown]
# ##################################################################
# This is a notebook that contains many hash signs.
# Hopefully its python representation is not recognized as a Sphinx Gal... | 30 | 896 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/convert_to_py_then_test_with_update83.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# region
# %%time
print('asdf')
# endregion
# Thanks for jupytext!
| 20 | 234 |
saleor | saleor/graphql/tax/tests/mutations/test_tax_configuration_update.py | .py | import graphene
import pytest
from django.test import override_settings
from .....core.tests.test_taxes import app_factory, tax_app_factory # noqa: F401
from .....plugins import PLUGIN_IDENTIFIER_PREFIX
from .....plugins.tests.sample_plugins import PluginSample
from .....tax.error_codes import TaxConfigurationUpdateE... | 737 | 22,964 |
probability | tensorflow_probability/python/bijectors/gompertz_cdf_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 91 | 3,653 |
pyomo | pyomo/common/collections/_hasher.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 71 | 2,628 |
rich-cli | tests/test_main.py | .py | import click
from click import Command
from click.decorators import FC, Parameter
from click.testing import CliRunner
class DuplicateOptionsError(ValueError):
pass
def test_duplicate_option_flags_raises_exception(monkeypatch):
"""Create a test that will monkeypatch the click.option decorators
so that th... | 42 | 1,524 |
pdm | tests/cli/test_self_command.py | .py | from types import SimpleNamespace
from unittest.mock import ANY
import pytest
from pdm import termui
from pdm.cli.commands import self_cmd
def mock_distribution(metadata, entry_points=()):
entry_points = (SimpleNamespace(group=ep) for ep in entry_points)
return SimpleNamespace(metadata=metadata, entry_point... | 250 | 8,859 |
sphinx | sphinx/ext/autodoc/_dynamic/_type_annotations.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.util import inspect
from sphinx.util.typing import stringify_annotation
if TYPE_CHECKING:
from collections.abc import Mapping
from typing import Any
from sphinx.util.typing import _StringifyMode
def _record_typehints(
... | 46 | 1,387 |
wagtail | wagtail/documents/models.py | .py | import os.path
import urllib
from contextlib import contextmanager
from mimetypes import guess_type
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import FileExtensionValidator
from django.db import models
from django.dispatch import Signal
from django.u... | 227 | 6,914 |
wagtail | wagtail/tests/actions/test_registry.py | .py | from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import TestCase
from wagtail import hooks
from wagtail.actions import (
CopyForTranslationAction,
CreateAction,
DeleteAction,
EditAction,
)
from wagtail.actions.base import BaseAction
from wagtail.acti... | 144 | 4,968 |
probability | tensorflow_probability/python/sts/components/autoregressive_test.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 187 | 6,933 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Bucketize.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
from common.utils.tf_utils import mix_array_with_several_values
rng = np.random.default_rng(3476123)
cla... | 69 | 3,113 |
saleor | saleor/graphql/menu/mutations/menu_item_create.py | .py | import graphene
from django.core.exceptions import ValidationError
from django.db.models import Model
from ....menu import models
from ....menu.error_codes import MenuErrorCode
from ....page import models as page_models
from ....permission.enums import MenuPermissions
from ....product import models as product_models
f... | 120 | 4,302 |
probability | tensorflow_probability/python/distributions/joint_distribution.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 1,570 | 66,517 |
pyfilesystem2 | fs/opener/osfs.py | .py | # coding: utf-8
"""`OSFS` opener definition.
"""
from __future__ import absolute_import, print_function, unicode_literals
import typing
from .base import Opener
from .registry import registry
if typing.TYPE_CHECKING:
from typing import Text
from ..osfs import OSFS # noqa: F401
from .parse import Parse... | 42 | 924 |
pyro | examples/sparse_regression.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import math
import numpy as np
import torch
from torch.optim import Adam
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer import Trace_ELBO
from pyro.infer.autoguide import Au... | 380 | 13,618 |
black | tests/data/cases/preview_wrap_comprehension_in.py | .py | # flags: --preview --line-length=79
[a for graph_path_expression in refined_constraint.condition_as_predicate.variables]
[
a
for graph_path_expression in refined_constraint.condition_as_predicate.variables
]
[
a
for graph_path_expression
in refined_constraint.condition_as_predicate.variables
]
[
... | 186 | 5,581 |
biopython | Bio/PDB/cealign.py | .py | # Copyright (C) 2022, Joao Rodrigues (j.p.g.l.m.rodrigues@gmail.com)
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Protein S... | 194 | 7,535 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.