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 |
|---|---|---|---|---|---|
saleor | saleor/graphql/order/tests/queries/test_order_granted_refunds.py | .py | from decimal import Decimal
import graphene
from prices import Money, TaxedMoney
from saleor.payment import TransactionEventType
from ....core.utils import to_global_id_or_none
from ....tests.utils import assert_no_permission, get_graphql_content
from ...enums import OrderGrantedRefundStatusEnum
ORDERS_QUERY = """
... | 632 | 19,753 |
pyomo | pyomo/opt/solver/ilmcmd.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... | 85 | 3,336 |
mlflow | tests/entities/test_gateway_budget_policy.py | .py | import pytest
from mlflow.entities.gateway_budget_policy import (
BudgetAction,
BudgetDuration,
BudgetDurationUnit,
BudgetTargetScope,
BudgetUnit,
GatewayBudgetPolicy,
)
def _make_policy(**overrides):
kwargs = {
"budget_policy_id": "bp-1",
"budget_unit": BudgetUnit.USD,
... | 78 | 2,519 |
probability | tensorflow_probability/python/internal/implementation_selection.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... | 158 | 5,866 |
wagtail | wagtail/sites/forms.py | .py | from django import forms
from django.utils.translation import gettext_lazy as _
from wagtail.admin.widgets import AdminPageChooser
from wagtail.models import Site
class SiteForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["root_page"].widge... | 22 | 665 |
pyro | pyro/contrib/gp/parameterized.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
from collections import OrderedDict
from functools import partial
from torch.distributions import biject_to, constraints
from torch.nn import Parameter
import pyro
import pyro.distributions as dist
from pyro.distr... | 213 | 8,052 |
wandb | wandb/integration/diffusers/resolvers/multimodal.py | .py | import logging
from collections.abc import Sequence
from typing import Any
import wandb
from wandb.sdk.integration_utils.auto_logging import Response
from .utils import (
chunkify,
decode_sdxl_t2i_latents,
get_updated_kwargs,
postprocess_np_arrays_for_video,
postprocess_pils_to_np,
)
logger = log... | 883 | 30,005 |
confluent-kafka-python | src/confluent_kafka/_oauthbearer/__init__.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... | 20 | 803 |
wandb | wandb/plot/custom_chart.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any
import wandb
@dataclass
class CustomChartSpec:
spec_name: str
fields: dict[str, Any]
string_fields: dict[str, Any]
key: str = ""
panel_type: str = "Vega2"
split_table: bool = False
@property
... | 148 | 5,010 |
omegaconf | tests/interpolation/test_custom_resolvers.py | .py | import random
import re
from typing import Any
from pytest import mark, param, raises, warns
from omegaconf import OmegaConf, Resolver
from omegaconf.nodes import InterpolationResultNode
from tests import User
from tests.interpolation import dereference_node
def legacy_register_resolver(name: str, resolver: Resolve... | 505 | 15,966 |
django-cms | cms/test_utils/project/customuserapp/models.py | .py | import re
from urllib.parse import quote
from django.contrib.auth.models import (
AbstractBaseUser,
PermissionsMixin,
UserManager,
)
from django.core import validators
from django.core.mail import send_mail
from django.db import models
from django.utils import timezone
from django.utils.translation import ... | 91 | 2,975 |
lemur | lemur/auth/service.py | .py | """
.. module: lemur.auth.service
:platform: Unix
:synopsis: This module contains all of the authentication duties for
lemur
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
import b... | 248 | 8,921 |
ipython | tests/test_magic.py | .py | # -*- coding: utf-8 -*-
"""Tests for various magic functions."""
import collections
import gc
import io
import json
import os
import platform
import re
import shlex
import signal
import sys
import warnings
from importlib import invalidate_caches
from io import StringIO
from pathlib import Path
from time import sleep
f... | 1,988 | 56,220 |
openvino | tests/layer_tests/pytorch_tests/test_aminmax.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestAminMax(PytorchLayerTest):
def _prepare_input(self, inputs, dtype=None):
import numpy as np
return [np.array(inputs).astype(... | 60 | 2,224 |
probability | tensorflow_probability/python/stats/leave_one_out_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... | 263 | 10,547 |
onnxruntime | onnxruntime/test/testdata/make_conv_default_attrs.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import numpy as np
import onnx
def main():
inp_shape = (1, 2, 8, 8)
input_0 = onnx.helper.make_tensor_value_info("input_0", onnx.TensorProto.FLOAT, inp_shape)
output_0 = onnx.helper.make_tensor_value_info("outpu... | 37 | 1,276 |
conda | conda/base/context.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda's global configuration object.
The context aggregates all configuration files, environment variables, and command line arguments
into one global stateful object to be used across all of conda.
"""
from __future__ import annotations
i... | 2,350 | 88,229 |
ipython | tests/test_io.py | .py | # encoding: utf-8
"""Tests for io.py"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import sys
from io import StringIO
import pytest
from IPython.utils.io import Tee, capture_output
def test_tee_simple():
"Very simple check with stdout only"
chan = ... | 72 | 1,529 |
readthedocs.org | readthedocs/projects/forms.py | .py | """Project forms."""
import json
import re
from random import choice
from re import fullmatch
from urllib.parse import urlparse
import dns.name
import dns.resolver
from allauth.socialaccount.models import SocialAccount
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Field
from crispy_forms.... | 1,556 | 58,118 |
cvxpy | cvxpy/atoms/affine/stack.py | .py | """
Copyright, 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, software
... | 108 | 3,485 |
readthedocs.org | readthedocs/rtd_tests/tests/test_core_utils.py | .py | """Test core util functions."""
from unittest import mock
import pytest
from django.conf import settings
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from readthedocs.builds.constants import BUILD_STATE_BUILDING, LATEST
from readthedocs.builds.models import Build, Version... | 243 | 8,540 |
probability | tensorflow_probability/python/bijectors/frechet_cdf.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... | 178 | 6,830 |
coremltools | coremltools/test/optimize/torch/quantization/test_learnable_fake_quantize.py | .py | # Copyright (c) 2025, 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 pytest
import torch
import torch.ao.quantization as aoquant
from coremltools.optimize.torch.q... | 314 | 8,851 |
beam | sdks/python/apache_beam/testing/benchmarks/inference/mltransform_generate_vocab_benchmark.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... | 57 | 2,408 |
metrics | src/torchmetrics/retrieval/recall.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... | 161 | 6,516 |
astropy | astropy/io/fits/tests/test_core.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import errno
import gzip
import http.client
import io
import mmap
import os
import pathlib
import shutil
import sys
import urllib.request
import zipfile
from unittest.mock import Mock, patch
import numpy as np
import pytest
from astropy.io import fits
fr... | 1,699 | 62,188 |
mlflow | tests/assistant/test_gateway_connection.py | .py | from types import SimpleNamespace
from unittest import mock
import pytest
from mlflow.assistant.gateway_connection import ensure_gateway_connection
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import RESOURCE_DOES_NOT_EXIST
def _not_found() -> MlflowException:
return MlflowExc... | 77 | 2,769 |
pyro | pyro/distributions/score_parts.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from typing import NamedTuple, Optional, Union
import torch
from pyro.distributions.util import scale_and_mask
class ScoreParts(NamedTuple):
"""
This data structure stores terms used in stochastic gradient estimators th... | 39 | 1,282 |
ipython | tests/test_backgroundjobs.py | .py | """Tests for pylab tools module."""
# -----------------------------------------------------------------------------
# Copyright (c) 2011, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -------... | 282 | 7,977 |
saleor | saleor/graphql/translations/mutations/product_variant_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, ProductVariantTranslateErrorCode
f... | 139 | 4,694 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_global_aggregate.py | .py | # coding=utf-8
#
# 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");... | 71 | 2,390 |
loguru | loguru/_contextvars.py | .py | import sys
def load_contextvar_class():
if sys.version_info >= (3, 7):
from contextvars import ContextVar
elif sys.version_info >= (3, 5, 3):
from aiocontextvars import ContextVar
else:
from contextvars import ContextVar
return ContextVar
ContextVar = load_contextvar_class()... | 16 | 321 |
mlflow | mlflow/genai/scorers/job.py | .py | """Huey job functions for async scorer invocation."""
import logging
import os
import random
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor, as_completed
from contextlib import nullcontext
from dataclasses import asdict, dataclass, field
from typing import Any
from mlflow.entiti... | 517 | 18,719 |
mlflow | tests/dev/test_classify_flaky_tests.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev"))
from classify_flaky_tests import _aggregate
def test_aggregate_collapses_events_per_test_and_counts():
flakes = [
{"shard": "python (1)", "test": "tests/a.py::t1", "error": "boom"},
{"shard":... | 37 | 1,370 |
probability | tensorflow_probability/python/experimental/nn/util/kernel_bias_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... | 67 | 2,420 |
qutip | qutip/tests/test_visualization.py | .py | import pytest
import qutip
import numpy as np
from qutip.wigner import sph_harm_y
mpl = pytest.importorskip("matplotlib")
plt = pytest.importorskip("matplotlib.pyplot")
def test_cyclic():
qutip.settings.colorblind_safe = True
rho = qutip.rand_dm(5)
fig, ax = qutip.hinton(rho, color_style='phase')
plt... | 715 | 19,618 |
pyomo | pyomo/network/plugins/__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... | 13 | 610 |
wandb | wandb/proto/v6/wandb_sync_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: wandb/proto/wandb_sync.proto
# Protobuf Python Version: 6.30.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_... | 58 | 4,242 |
probability | tensorflow_probability/examples/statistical_rethinking/rethinking/quap_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... | 162 | 5,682 |
returns | tests/test_future/test_future_container/test_future_decorator.py | .py | import anyio
import pytest
from returns.future import Future, future
from returns.io import IO
@future
async def _coro(arg: int) -> float:
assert isinstance(arg, int)
await anyio.sleep(0)
return arg / 2
@pytest.mark.anyio
async def test_safe_decorator():
"""Ensure that coroutine marked with ``@futu... | 22 | 471 |
pyomo | pyomo/core/tests/unit/kernel/test_matrix_constraint.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... | 1,186 | 44,790 |
voila | tests/server/cwd_subdir_test.py | .py | # NOTE: this is a duplicate of ../app/cwd_subdir_test.py
# we might want to find a better pattern of executing test for the app and extension
import pytest
@pytest.fixture
def cwd_subdir_notebook_url(base_url):
return base_url + "voila/render/subdir/cwd_subdir.ipynb"
@pytest.fixture
def voila_args(notebook_dire... | 20 | 661 |
scikit-bio | skbio/test.py | .py | """Run pytest in scikit-bio configuration.
----------------------------------------------------------------------------
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.
------------... | 17 | 474 |
probability | tensorflow_probability/python/experimental/distribute/sharded.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... | 197 | 7,782 |
kombu | kombu/asynchronous/timer.py | .py | """Timer scheduling Python callbacks."""
from __future__ import annotations
import heapq
import sys
from collections import namedtuple
from datetime import datetime
from functools import total_ordering
from time import monotonic
from time import time as _time
from typing import TYPE_CHECKING
from weakref import proxy... | 242 | 6,922 |
coremltools | coremltools/optimize/torch/quantization/_backend_config_utils.py | .py | # Copyright (c) 2024, 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
from copy import deepcopy as _deepcopy
from typing import Any as _Any
from typing import Callable as ... | 451 | 14,593 |
lemur | lemur/api_keys/cli.py | .py | """
.. module: lemur.api_keys.cli
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Eric Coan <kungfury@instructure.com>
"""
from datetime import datetime
import click
from flask.cli import with_appcontext
from lemu... | 67 | 1,717 |
kafka | tests/kafkatest/services/transactional_message_copier.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 use ... | 211 | 9,745 |
flit | flit_core/build_dists.py | .py | """Build flit_core to upload to PyPI.
Normally, this should only be used by me when making a release.
"""
import os
from flit_core import buildapi
os.chdir(os.path.dirname(os.path.abspath(__file__)))
print("Building sdist")
sdist_fname = buildapi.build_sdist('dist/')
print(os.path.join('dist', sdist_fname))
print(... | 18 | 421 |
saleor | saleor/graphql/webhook/tests/mutations/test_webhook_dry_run.py | .py | import json
import uuid
import graphene
from .....graphql.shop.types import SHOP_ID
from .....graphql.tests.utils import get_graphql_content
from .....webhook.error_codes import WebhookDryRunErrorCode
from .....webhook.event_types import WebhookEventAsyncType
from ....tests.utils import assert_no_permission
from ...s... | 386 | 12,569 |
clearml | examples/frameworks/keras/legacy/keras_tensorboard.py | .py | # ClearML - Keras with Tensorboard example code, automatic logging model and Tensorboard outputs
#
# Train a simple deep NN on the MNIST dataset.
# Gets to 98.40% test accuracy after 20 epochs
# (there is *a lot* of margin for parameter tuning).
# 2 seconds per epoch on a K520 GPU.
from __future__ import print_function... | 119 | 4,206 |
saleor | saleor/tests/e2e/checkout/zero_total/test_0_total_checkout_with_order_promotion_and_free_shipping.py | .py | import pytest
from ...product.utils.preparing_product import prepare_products
from ...promotions.utils import create_promotion
from ...shop.utils.preparing_shop import prepare_shop
from ...utils import assign_permissions
from ..utils import (
checkout_complete,
checkout_create,
checkout_delivery_method_upd... | 258 | 9,662 |
readthedocs.org | readthedocs/core/models.py | .py | """Models for the core app."""
from django.contrib.auth.models import User
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django_extensions.db.models import TimeStampedModel
from simple_history import register
from readthedocs.core.history impo... | 80 | 2,414 |
gunicorn | tests/docker/asgi_framework_compat/scripts/generate_grid.py | .py | #!/usr/bin/env python3
"""
Compatibility Grid Generator
Generates a compatibility matrix showing test results for each
ASGI framework tested with gunicorn's native ASGI worker.
"""
import json
import os
from datetime import datetime
from pathlib import Path
# Framework configuration
FRAMEWORKS = ["django", "fastapi... | 199 | 5,466 |
saleor | saleor/core/tests/test_notification.py | .py | import pytest
from django.core.exceptions import ValidationError
from ...core.notification.validation import validate_and_get_channel
from ...graphql.notifications.error_codes import ExternalNotificationErrorCodes
def test_validate_and_get_channel_for_non_existing_slug():
with pytest.raises(ValidationError):
... | 35 | 1,124 |
hatch | tests/cli/env/test_lock.py | .py | import os
import pytest
import tomli_w
from hatch.config.constants import ConfigEnvVars
from hatch.env.lockers.uv import UvLocker
from hatch.project.core import Project
from hatch.utils.toml import load_toml_file
def _require_uv(uv_on_path: str | None) -> None:
if not uv_on_path:
pytest.skip("uv not fou... | 1,196 | 38,987 |
wandb | wandb/automations/_generated/input_types.py | .py | # Generated by ariadne-codegen
# Source: core/api/graphql/schemas/schema-latest.graphql
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLId, GQLInput
from .enums import (
AlertSeverity,
EventTriggeringConditionType,
TriggeredActionType,
TriggerScopeType,
)... | 112 | 3,853 |
wagtail | wagtail/coreutils.py | .py | import functools
import inspect
import logging
import re
import unicodedata
from collections.abc import Iterable
from hashlib import md5
from typing import TYPE_CHECKING, Any
from anyascii import anyascii
from django.apps import apps
from django.conf import settings
from django.conf.locale import LANG_INFO
from django... | 619 | 22,045 |
mlflow | tests/telemetry/test_client.py | .py | import json
import logging
import threading
import time
import warnings
from unittest import mock
import pytest
import mlflow
from mlflow.environment_variables import (
_MLFLOW_TELEMETRY_PRE_WARM_DATABRICKS_SDK,
_MLFLOW_TELEMETRY_SESSION_ID,
MLFLOW_ENABLE_DB_SDK,
)
from mlflow.telemetry.client import (
... | 1,409 | 48,877 |
saleor | saleor/page/tests/test_tasks.py | .py | from unittest.mock import patch
from ..models import Page
from ..tasks import mark_pages_search_vector_as_dirty, update_pages_search_vector_task
@patch("saleor.page.tasks.update_pages_search_vector")
def test_update_pages_search_vector(update_pages_search_vector_mock, page_list):
"""Test updating search vector w... | 49 | 1,314 |
pdm | src/pdm/cli/commands/build.py | .py | from __future__ import annotations
import argparse
import os
import shutil
import sys
import tarfile
import tempfile
from collections.abc import Mapping
from pathlib import Path
from pdm.cli.commands.base import BaseCommand
from pdm.cli.hooks import HookManager
from pdm.cli.options import (
config_setting_option,... | 152 | 5,987 |
saleor | saleor/shipping/interface.py | .py | from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Optional
import graphene
import graphql
from measurement.measures import Weight
from prices import Money
from ..graphql.core.utils import from_global_id_or_error
from ..plugins.const import APP_ID_PREFIX
if TYPE_CHECKING:
from ..tax.model... | 60 | 1,599 |
saleor | saleor/tests/test_db_connections.py | .py | import pytest
from django.conf import settings
from ..app.models import App, AppExtension
def test_subqueries_no_allowed_across_different_databases(app_with_extensions):
replica = settings.DATABASE_CONNECTION_REPLICA_NAME
writer = settings.DATABASE_CONNECTION_DEFAULT_NAME
subquery = App.objects.using(rep... | 17 | 541 |
saleor | saleor/plugins/avatax/tests/test_avatax_caching.py | .py | from copy import deepcopy
from decimal import Decimal
from unittest.mock import ANY, Mock, patch
from django.test import override_settings
from prices import Money, TaxedMoney
from ....checkout.fetch import fetch_checkout_lines
from ...manager import get_plugins_manager
from .. import CACHE_KEY, generate_request_data... | 716 | 25,832 |
bazel | tools/jdk/proguard_allowlister.py | .py | # Copyright 2015 The Bazel Authors. All rights reserved.
#
# 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 la... | 105 | 3,830 |
onnxruntime | cgmanifests/print_submodule_info.py | .py | #!/usr/bin/env python3
# args: <submodule path>
# output: <path> <url> <commit>
import subprocess
import sys
assert len(sys.argv) == 2
path = sys.argv[1]
proc = subprocess.run(
["git", "config", "--get", "remote.origin.url"],
check=True,
cwd=path,
stdout=subprocess.PIPE,
text=True,
)
url = pro... | 28 | 510 |
beam | sdks/python/apache_beam/io/requestresponse_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... | 184 | 6,356 |
python-prompt-toolkit | src/prompt_toolkit/shortcuts/choice_input.py | .py | from __future__ import annotations
from collections.abc import Sequence
from typing import Generic, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.filters import (
Condition,
FilterOrBool,
is_done,
renderer_height_is_known,
to_filter,
)
from prompt_toolkit.formatted... | 316 | 10,724 |
readthedocs.org | readthedocs/rtd_tests/tests/test_single_version.py | .py | import django_dynamic_fixture as fixture
from django.test import TestCase
from django.test.utils import override_settings
from readthedocs.projects.constants import (
MULTIPLE_VERSIONS_WITH_TRANSLATIONS,
SINGLE_VERSION_WITHOUT_TRANSLATIONS,
)
from readthedocs.projects.models import Project
@override_settings... | 37 | 1,050 |
black | src/blib2to3/pgen2/token.py | .py | """Token constants (from "token.h")."""
from typing import Final
# Taken from Python (r53757) and modified to include some tokens
# originally monkeypatched in by pgen2.tokenize
# --start constants--
ENDMARKER: Final = 0
NAME: Final = 1
NUMBER: Final = 2
STRING: Final = 3
NEWLINE: Final = 4
INDENT: Final = 5
DEDE... | 85 | 1,810 |
biopython | Bio/SeqIO/PhdIO.py | .py | # Copyright 2008-2016 by Peter Cock. All rights reserved.
# Revisions copyright 2009 by Cymon J. Cox. All rights reserved.
#
# 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 hav... | 171 | 6,391 |
mlflow | tests/tracing/helper.py | .py | import os
import time
import uuid
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass, field
from typing import Any
from unittest import mock
import opentelemetry.trace as trace_api
import pytest
from opentelemetry.sdk.trace import Event, ReadableSpan
from opentelemetry.sdk.trace.export... | 349 | 11,869 |
saleor | saleor/graphql/order/tests/mutations/test_order_grant_refund_create.py | .py | from decimal import Decimal
import graphene
import pytest
from .....core.prices import quantize_price
from .....order.utils import update_order_charge_data
from ....core.utils import to_global_id_or_none
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
)
from ...enums import (
Orde... | 1,153 | 36,137 |
wandb | tests/unit_tests/test_profiler.py | .py | import pytest
import wandb
from wandb.errors import UsageError
def test_profiler_without_init():
pytest.importorskip("torch")
import torch
with pytest.raises(UsageError) as e_info:
with torch.profiler.profile(
schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=1),
... | 22 | 615 |
pyomo | pyomo/contrib/cp/transform/logical_to_disjunctive_program.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... | 139 | 5,994 |
django-cms | cms/tests/test_page_user_admin.py | .py | from unittest.mock import patch
from django.contrib import admin
from django.contrib.auth import get_permission_codename, get_user_model
from django.contrib.messages.storage.cookie import CookieStorage
from django.contrib.sites.models import Site
from django.core.exceptions import PermissionDenied
from django.forms.mo... | 686 | 26,808 |
beam | learning/tour-of-beam/learning-content/common-transforms/aggregation/sum/python-example/task.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"); y... | 52 | 1,710 |
probability | tensorflow_probability/python/experimental/distributions/importance_resample_test.py | .py | # Copyright 2021 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... | 286 | 12,740 |
beam | sdks/python/apache_beam/examples/complete/tfidf_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... | 59 | 2,145 |
pyfilesystem2 | fs/wrapfs.py | .py | """Base class for filesystem wrappers.
"""
from __future__ import unicode_literals
import typing
import six
from . import errors
from .base import FS
from .copy import copy_dir, copy_file
from .error_tools import unwrap_errors
from .info import Info
from .path import abspath, join, normpath
if typing.TYPE_CHECKING... | 548 | 17,457 |
sphinx | tests/roots/test-ext-doctest-fail-fast/conf.py | .py | extensions = ['sphinx.ext.doctest']
project = 'test project for doctest'
root_doc = 'fail-fast'
source_suffix = {
'.txt': 'restructuredtext',
}
exclude_patterns = ['_build']
# Set in tests.
# doctest_fail_fast = ...
| 12 | 222 |
mlflow | tests/gateway/providers/test_bedrock.py | .py | import io
from unittest import mock
import pytest
from fastapi.encoders import jsonable_encoder
from mlflow.gateway.config import (
AmazonBedrockConfig,
AWSBaseConfig,
AWSIdAndKey,
AWSRole,
EndpointConfig,
)
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.bed... | 790 | 27,724 |
pyomo | pyomo/contrib/gdpopt/tests/test_LBB.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... | 290 | 12,067 |
wandb | wandb/sdk/artifacts/artifact.py | .py | """Artifact class."""
from __future__ import annotations
import atexit
import contextlib
import json
import logging
import multiprocessing.dummy
import os
import re
import shutil
import stat
import tempfile
import time
from collections import deque
from collections.abc import Generator, Sequence
from concurrent.futur... | 2,752 | 106,358 |
saleor | saleor/attribute/search.py | .py | from typing import Union
from django.db.models import QuerySet, Value
from ..attribute import AttributeInputType
from ..core.editorjs import editorjs_to_text
from ..core.postgres import NoValidationSearchVector
from .models import Attribute, AttributeValue
def get_search_vectors_for_attribute_values(
attribute:... | 94 | 3,152 |
beam | sdks/python/apache_beam/transforms/trigger_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... | 1,458 | 50,481 |
black | src/blib2to3/pgen2/driver.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Modifications:
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Parser driver.
This provides a high-level interface to parse a file into a synta... | 322 | 10,709 |
ipython | tests/test_pickleshare.py | .py | """Tests for the vendored pickleshare module."""
import errno
from pathlib import Path
import pytest
from IPython.external.pickleshare import PickleShareDB, PickleShareLink, gethashfile
@pytest.fixture
def db(tmp_path):
return PickleShareDB(tmp_path / "pickleshare")
def test_init_creates_directory(tmp_path):... | 320 | 9,940 |
gunicorn | tests/docker/asgi_compliance/test_http2_asgi.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
HTTP/2 ASGI integration tests.
Tests HTTP/2 specific functionality with ASGI applications.
"""
import json
import pytest
pytestmark = [
pytest.mark.docker,
pytest.mark.asgi,
pytest.mark.http2,
... | 441 | 16,726 |
luigi | test/contrib/esindex_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... | 314 | 11,522 |
pymc | pymc/gp/hsgp_approx.py | .py | # Copyright 2024 - present The PyMC Developers
#
# 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... | 769 | 29,104 |
saleor | saleor/graphql/menu/tests/queries/test_menus.py | .py | import pytest
from .....menu.models import Menu
from ....tests.utils import get_graphql_content
@pytest.fixture
def menus_for_pagination(db):
# We have "footer" and "navbar" from default saleor configuration
return Menu.objects.bulk_create(
[
Menu(name="menu1", slug="menu1"),
... | 109 | 2,830 |
ipython | IPython/core/completer.py | .py | """Completion for IPython.
This module started as fork of the rlcompleter module in the Python standard
library. The original enhancements made to rlcompleter have been sent
upstream and were accepted as of Python 2.3,
This module now support a wide variety of completion mechanism both available
for normal classic P... | 3,884 | 137,969 |
returns | tests/test_contrib/test_hypothesis/test_type_resolver.py | .py | from typing import Generic, TypeVar
from hypothesis import strategies as st
from returns.contrib.hypothesis.type_resolver import (
look_up_strategy,
strategies_for_types,
)
_ValueType = TypeVar('_ValueType')
class _Wrapper1(Generic[_ValueType]):
_inner_value: _ValueType
class _Wrapper2(Generic[_Value... | 67 | 2,206 |
hatch | tests/utils/test_structures.py | .py | import os
from hatch.utils.structures import EnvVars
def get_random_name():
return os.urandom(16).hex().upper()
class TestEnvVars:
def test_restoration(self):
num_env_vars = len(os.environ)
with EnvVars():
os.environ.clear()
assert len(os.environ) == num_env_vars
d... | 62 | 1,698 |
beam | sdks/python/apache_beam/ml/anomaly/univariate/median.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... | 68 | 2,523 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean_globally.py | .py | # coding=utf-8
#
# 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");... | 54 | 1,557 |
wagtail | wagtail/images/widgets.py | .py | from django import forms
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from wagtail.admin.staticfiles import versioned_static
from wagtail.admin.telepath import register
from wagtail.admin.widgets import BaseChooser, BaseChooserAdapter
from wagtail.images im... | 68 | 2,372 |
openvino | tests/e2e_tests/conftest.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pathlib
import sys
from cpuinfo import get_cpu_info
from e2e_tests.common.logger import get_logger
from .common.sys_info_utils import get_sys_info
from e2e_tests.test_utils.tf_helper import TFVersionHelper
try:
# In user_co... | 70 | 2,713 |
biopython | Bio/SeqIO/FastaIO.py | .py | # Copyright 2006-2017,2020 by Peter Cock. All rights reserved.
#
# 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.
#
# This module is... | 687 | 22,400 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.