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 |
|---|---|---|---|---|---|
gunicorn | tests/requests/invalid/pp_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
from gunicorn.http.errors import InvalidProxyLine
cfg = Config()
cfg.set("proxy_protocol", True)
request = InvalidProxyLine
| 12 | 267 |
wandb | wandb/sdk/lib/service/service_client.py | .py | from __future__ import annotations
import asyncio
import logging
import struct
from types import TracebackType
from wandb.proto import wandb_server_pb2 as spb
from wandb.sdk.lib import asyncio_manager
from wandb.sdk.mailbox.mailbox import Mailbox
from wandb.sdk.mailbox.mailbox_handle import MailboxHandle
_logger = l... | 145 | 4,664 |
saleor | saleor/graphql/app/tests/queries/test_app_extension.py | .py | import graphene
import pytest
from .....app.models import App, AppExtension
from .....app.types import AppType
from .....core.jwt import jwt_decode
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
get_graphql_content_from_response,
)
QUERY_APP_EXTENSION = """
query ($id: ID!){
... | 725 | 21,220 |
coveragepy | lab/parser.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
"""Parser.py: a main for invoking code in coverage/parser.py"""
import collections
import dis
import glob
import optparse
import os
import re
import sys
import t... | 221 | 7,482 |
probability | tensorflow_probability/python/vi/__init__.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... | 73 | 3,193 |
pymc | pymc/gp/gp.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... | 1,312 | 50,144 |
marshmallow | tests/test_fields.py | .py | import pytest
from marshmallow import (
EXCLUDE,
INCLUDE,
RAISE,
Schema,
ValidationError,
fields,
missing,
)
from marshmallow.exceptions import StringNotCollectionError
from marshmallow.orderedset import OrderedSet
from tests.base import ALL_FIELDS
@pytest.mark.parametrize(
("alias", ... | 756 | 27,882 |
coveragepy | lab/run_sysmon.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
"""Run sys.monitoring on a file of Python code."""
import functools
import sys
print(sys.version)
the_program = sys.argv[1]
code = compile(open(the_program, en... | 120 | 3,521 |
mamba | libmambapy/src/libmambapy/solver/__init__.py | .py | from libmambapy.bindings.solver import * # noqa: F403
import libmambapy.solver.libsolv # noqa: F401
| 3 | 102 |
textual | tests/snapshot_tests/snapshot_apps/data_table_add_column.py | .py | from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import DataTable, Footer
MOVIES = [
"Severance",
"Foundation",
"Dark",
"The Boys",
"The Last of Us",
"Lost in Space",
"Altered Carbon",
]
class AddColumn(App):
BINDINGS = [
Bind... | 39 | 921 |
mlflow | tests/server/test_security.py | .py | import logging
import pytest
from fastapi import FastAPI
from flask import Flask
from starlette.testclient import TestClient
from werkzeug.test import Client
from mlflow.server import security
from mlflow.server.fastapi_security import init_fastapi_security
from mlflow.server.security_utils import is_allowed_host_hea... | 438 | 15,532 |
probability | tensorflow_probability/python/distributions/sample_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... | 589 | 25,724 |
django-cms | cms/views.py | .py | from urllib.parse import quote, urlsplit, urlunsplit
from django.apps import apps
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME, login as auth_login
from django.contrib.auth.views import redirect_to_login
from django.contrib.contenttypes.models import ContentType
from django.core... | 436 | 18,521 |
ipython | IPython/display.py | .py | """Public API for display tools in IPython."""
# -----------------------------------------------------------------------------
# Copyright (C) 2012 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 software.
... | 42 | 1,392 |
openvino | tests/e2e_tests/pipelines/pipeline_templates/postproc_template.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""ing templates processed by testing framework.
"""
from collections import OrderedDict
from e2e_tests.common.decorators import wrap_ord_dict
@wrap_ord_dict
def squeeze(axis=(2, 3)):
"""Construct squeezing action.
:param axi... | 104 | 3,644 |
scikit-bio | skbio/stats/ordination/tests/test_ordination_results.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.
# --------------------------------------------... | 705 | 30,252 |
openvino | src/bindings/python/tests/test_graph/test_convolution.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from openvino import Type
import openvino.opset8 as ov
@pytest.mark.parametrize(("strides", "pads_begin", "pads_end", "dilations", "expected_shape"), [
(np.array([1, 1]), np... | 53 | 2,331 |
saleor | saleor/graphql/tax/tests/mutations/test_tax_class_update.py | .py | import graphene
from .....tax.error_codes import TaxClassUpdateErrorCode
from .....tax.models import TaxClass, TaxClassCountryRate
from ....tests.utils import assert_no_permission, get_graphql_content
from ..fragments import TAX_CLASS_FRAGMENT
MUTATION = (
"""
mutation TaxClassUpdate($id: ID!, $input: TaxClas... | 250 | 7,529 |
ipython | IPython/core/getipython.py | .py | """Simple function to call to get the current InteractiveShell instance"""
# -----------------------------------------------------------------------------
# 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... | 28 | 1,042 |
saleor | saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_tax_class.py | .py | import pytest
from ...product.utils import update_product
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_shop
from ...taxes.utils import update_country_tax_rates
from ...utils import assign_permissions
from ..utils import (
checkout_complete,
che... | 160 | 5,178 |
astropy | astropy/cosmology/_src/io/builtin/table.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| <-> |Table| I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| object to and from a |Table|
object. The functions are registered with ``convert_registry`` under the format... | 485 | 21,314 |
mlflow | tests/tracing/processor/test_inference_table_processor.py | .py | import json
from unittest import mock
import pytest
from mlflow.entities.span import LiveSpan
from mlflow.entities.trace_state import TraceState
from mlflow.tracing.constant import (
TRACE_SCHEMA_VERSION,
TRACE_SCHEMA_VERSION_KEY,
SpanAttributeKey,
TraceMetadataKey,
)
from mlflow.tracing.processor.inf... | 220 | 7,846 |
black | src/blackd/__main__.py | .py | import blackd
blackd.patched_main()
| 4 | 37 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_AddTypes.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng()
class TestAddTypes(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 57 | 2,632 |
openvino | tests/layer_tests/jax_tests/test_exp.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import jax
import numpy as np
import pytest
from jax import numpy as jnp
from jax_layer_test_class import JaxLayerTest
rng = np.random.default_rng(109734)
class TestExp(JaxLayerTest):
def _prepare_input(self):
if np.issub... | 46 | 1,559 |
wagtail | wagtail/contrib/simple_translation/tests/test_migrations.py | .py | from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from wagtail.test.utils import TestCase
class TestMigrations(TestCase):
def test_content_type_exists(self):
self.assertTrue(
ContentType.objects.filter(
app_label="simp... | 19 | 548 |
conda | conda/plugins/environment_specifiers/cep_24.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
**EXPERIMENTAL**
Register the conda env spec for environment.yml files.
"""
from .. import hookimpl
from ..types import CondaEnvironmentSpecifier
@hookimpl(tryfirst=True)
def conda_environment_specifiers():
from ...env.specs.cep_24 im... | 23 | 641 |
saleor | saleor/graphql/meta/tests/mutations/test_menu.py | .py | import graphene
from . import PUBLIC_KEY, PUBLIC_VALUE
from .test_delete_metadata import (
execute_clear_public_metadata_for_item,
item_without_public_metadata,
)
from .test_delete_private_metadata import (
execute_clear_private_metadata_for_item,
item_without_private_metadata,
)
from .test_update_meta... | 200 | 5,038 |
pdm | tests/fixtures/projects/demo-failure/setup.py | .py | from setuptools import setup
import first
setup(
name="demo",
version="0.0.1",
description="test demo",
py_modules=["demo"],
python_requires=">=3.3",
install_requires=["idna", "chardet; os_name=='nt'"],
extras_require={
"tests": ["pytest"],
"security": ['requests; python_ve... | 17 | 345 |
saleor | saleor/plugins/sendgrid/tasks.py | .py | import logging
from python_http_client import exceptions
from sendgrid import SendGridAPIClient, SendGridException
from sendgrid.helpers.mail import Mail
from ...account import events as account_events
from ...celeryconf import app
from ...core.db.connection import allow_writer
from ...giftcard import events as gift_... | 364 | 12,767 |
gunicorn | tests/requests/invalid/010.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
from gunicorn.http.errors import LimitRequestHeaders
request = LimitRequestHeaders
cfg = Config()
cfg.set('limit_request_field_size', 10)
| 11 | 280 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_FusedBatchNorm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from sys import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestFusedBatchNorm(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 111 | 5,603 |
coremltools | coremltools/converters/mil/testing_utils.py | .py | # Copyright (c) 2020, 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 copy
import itertools
import os
from functools import partial
from pathlib import Path
from typ... | 816 | 30,622 |
ipython | IPython/utils/sentinel.py | .py | """Sentinel class for constants with useful reprs"""
from __future__ import annotations
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
class Sentinel:
def __init__(self, name: str, module: str, docstring: str | None = None) -> None:
self.name = name
... | 17 | 489 |
readthedocs.org | readthedocs/organizations/tests/test_filters.py | .py | import django_dynamic_fixture as fixture
import pytest
from django.contrib.auth.models import User
from django.urls import reverse
from pytest_django.asserts import assertQuerySetEqual
from readthedocs.organizations.models import Organization, Team
from readthedocs.projects.models import Project
@pytest.mark.django_... | 600 | 18,910 |
sphinx | sphinx/errors.py | .py | """Contains SphinxError and a few subclasses."""
from __future__ import annotations
class SphinxError(Exception):
"""Base class for Sphinx errors.
This is the base class for "nice" exceptions. When such an exception is
raised, Sphinx will abort the build and present the exception category and
messa... | 140 | 3,413 |
astropy | astropy/utils/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains developer-oriented utilities used by Astropy.
Public functions and classes in this subpackage are safe to be used by other
packages, but this subpackage is for utilities that are primarily of use for
developers or to implement... | 22 | 813 |
pyro | pyro/contrib/timeseries/lgssmgp.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.nn as nn
from torch.distributions import MultivariateNormal, constraints
import pyro.distributions as dist
from pyro.contrib.timeseries.base import TimeSeriesModel
from pyro.nn import PyroParam, pyro_meth... | 275 | 11,260 |
saleor | saleor/tests/e2e/checkout/test_checkout_create_order_transactions_and_active_payment.py | .py | import pytest
from ....payment.error_codes import PaymentErrorCode
from ..apps.utils import add_app
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..transactions.utils import transaction_initialize
from ..utils import assign_permissions
f... | 121 | 3,523 |
probability | tensorflow_probability/python/distributions/zipf_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... | 430 | 16,094 |
wagtail | wagtail/users/views/api_tokens.py | .py | import django_filters
from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.forms import CharField, CheckboxSelectMultiple, Form, ModelChoiceField
from django.shortcuts import get_object_or_404, redirect
from django.urls import path, reverse
from django.utils.functional imp... | 287 | 10,006 |
coremltools | coremltools/converters/mil/backend/nn/passes/__init__.py | .py | # Copyright (c) 2020, 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 . import (
alert_return_type_cast,
commingle_loop_vars,
conv1d_decomposition,
ha... | 15 | 432 |
wagtail | wagtail/management/commands/move_pages.py | .py | import swapper
from django.core.management.base import BaseCommand
Page = swapper.load_model("wagtailcore", "Page")
class Command(BaseCommand):
def add_arguments(self, parser):
# Positional arguments
parser.add_argument("from_id", type=int)
parser.add_argument("to_id", type=int)
def ... | 33 | 884 |
python-prompt-toolkit | examples/prompts/confirmation-prompt.py | .py | #!/usr/bin/env python
"""
Example of a confirmation prompt.
"""
from prompt_toolkit.shortcuts import confirm
if __name__ == "__main__":
answer = confirm("Should we do that?")
print(f"You said: {answer}")
| 11 | 214 |
sphinx | sphinx/util/index_entries.py | .py | from __future__ import annotations
def split_index_msg(entry_type: str, value: str) -> list[str]:
# new entry types must be listed in util/nodes.py!
if entry_type == 'single':
try:
return _split_into(2, 'single', value)
except ValueError:
return _split_into(1, 'single',... | 28 | 995 |
python-prompt-toolkit | examples/prompts/asyncio-prompt.py | .py | #!/usr/bin/env python
"""
This is an example of how to prompt inside an application that uses the asyncio
eventloop. The ``prompt_toolkit`` library will make sure that when other
coroutines are writing to stdout, they write above the prompt, not destroying
the input line.
This example does several things:
1. It sta... | 64 | 1,808 |
saleor | saleor/graphql/menu/tests/queries/test_menu_item.py | .py | import graphene
from .....menu.models import MenuItem
from ....tests.utils import get_graphql_content, get_graphql_content_from_response
QUERY_MENU_ITEM_BY_ID = """
query menuitem($id: ID!, $channel: String) {
menuItem(id: $id, channel: $channel) {
name
children {
name
}
... | 226 | 6,670 |
mlflow | examples/llama_index/workflow/workflow/model.py | .py | from workflow.workflow import HybridRAGWorkflow
import mlflow
# Get model config from ModelConfig singleton (specified via `model_config` parameter when logging the model)
model_config = mlflow.models.ModelConfig()
retrievers = model_config.get("retrievers")
# Create the workflow instance.
workflow = HybridRAGWorkfl... | 15 | 577 |
saleor | saleor/plugins/user_email/notify_events.py | .py | from collections.abc import Callable
from typing import TYPE_CHECKING
from ..email_common import get_email_subject, get_email_template_or_default
from . import constants
from .tasks import (
send_account_confirmation_email_task,
send_account_delete_confirmation_email_task,
send_fulfillment_confirmation_ema... | 386 | 13,245 |
saleor | saleor/graphql/checkout/mutations/checkout_remove_promo_code.py | .py | import graphene
from django.core.exceptions import ValidationError
from graphql.error import GraphQLError
from ....checkout import models
from ....checkout.actions import call_checkout_info_event
from ....checkout.error_codes import CheckoutErrorCode
from ....checkout.fetch import fetch_checkout_info, fetch_checkout_l... | 191 | 6,664 |
saleor | saleor/plugins/tests/fixtures/gateway.py | .py | import pytest
@pytest.fixture(autouse=True)
def setup_dummy_gateway(settings):
settings.PLUGINS = ["saleor.plugins.tests.gateways.dummy.DummyGatewayPlugin"]
return settings
@pytest.fixture
def sample_gateway(settings):
settings.PLUGINS += [
"saleor.plugins.tests.sample_plugins.ActiveDummyPayment... | 16 | 355 |
ipython | IPython/__init__.py | .py | # PYTHON_ARGCOMPLETE_OK
"""
IPython: tools for interactive and parallel computing in Python.
https://ipython.org
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2008-2011, IPython Development Team.
# Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.e... | 196 | 8,324 |
mlflow | tests/utils/test_mime_type_utils.py | .py | import pytest
from mlflow.utils.mime_type_utils import _guess_mime_type
from mlflow.utils.os import is_windows
@pytest.mark.skipif(is_windows(), reason="This test fails on Windows")
@pytest.mark.parametrize(
("file_path", "expected_mime_type"),
[
("c.txt", "text/plain"),
("c.pkl", "applicatio... | 40 | 1,335 |
ipython | examples/IPython Kernel/ipython-get-history.py | .py | #!/usr/bin/env python
"""Extract a session from the IPython input history.
Usage:
ipython-get-history.py sessionnumber [outputfile]
If outputfile is not given, the relevant history is written to stdout. If
outputfile has a .py extension, the translated history (without IPython's
special syntax) will be extracted.
... | 42 | 1,139 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/Notebook with function and cell metadata 164.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
1 + 1
# A markdown cell
# And below, the cell for function f has non trivial cell metadata. And the next cell as well.
# region attributes={"classes": [],... | 30 | 473 |
sphinx | tests/roots/test-ext-autodoc/target/process_docstring.py | .py | def func():
"""first line
---
second line
---
third line
"""
| 8 | 85 |
mlflow | tests/store/tracking/test_rest_store_workspace.py | .py | from unittest import mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.protos.service_pb2 import Experiment, GetExperiment
from mlflow.store.tracking.rest_store import RestStore
from mlflow.utils.rest_utils import MlflowHostCreds
from mlflow.utils.server_info import SERVER_INFO_ENDPOINT, _c... | 186 | 6,637 |
readthedocs.org | readthedocs/api/v3/tests/test_versions.py | .py | from unittest import mock
import django_dynamic_fixture as fixture
from django.test import override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.constants import EXTERNAL, TAG
from readthedocs.builds.models import Version
from readthedocs.projects.constants i... | 456 | 16,586 |
wandb | wandb/sdk/lib/service/ipc_support.py | .py | """Constants determining what IPC methods are supported."""
import socket
SUPPORTS_UNIX = hasattr(socket, "AF_UNIX")
"""Whether Unix sockets are supported.
AF_UNIX is not supported on Windows:
https://github.com/python/cpython/issues/77589
Windows has supported Unix sockets since ~2017, but support in Python is
mis... | 14 | 341 |
onnxruntime | onnxruntime/test/testdata/transform/id-scan9_sum.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
initial = helper.make_tensor_value_info("initial", TensorProto.FLOAT, [2])
x = helper.make_tensor_value_info("x", TensorProto.FLOAT, [3, 2])
y = helper.make_tensor_value_info("y", TensorProto.FLOAT, [3, 2])
z = helper.make_tensor_value_info("z", Tens... | 41 | 1,626 |
coremltools | coremltools/optimize/torch/_utils/validation_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
import copy as _copy
import logging as _logging
from typing import Dict as _Dict
from typing import L... | 190 | 7,424 |
pymc | tests/backends/test_base.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... | 56 | 1,966 |
onnxruntime | onnxruntime/test/python/transformers/bert_model_generator.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ... | 631 | 23,635 |
saleor | saleor/webhook/transport/tests/test_utils.py | .py | import datetime
import json
from unittest.mock import ANY, MagicMock, patch
import pytest
from celery import Task
from celery.exceptions import Retry
from celery.utils.threads import LocalStack
from ....core import EventDeliveryStatus
from ....core.models import EventDelivery, EventDeliveryAttempt
from ...event_types... | 429 | 12,797 |
readthedocs.org | readthedocs/search/tests/test_proxied_api.py | .py | import pytest
from corsheaders.middleware import ACCESS_CONTROL_ALLOW_ORIGIN
from readthedocs.search.tests.test_api import BaseTestDocumentSearch
@pytest.mark.proxito
@pytest.mark.search
class TestProxiedSearchAPI(BaseTestDocumentSearch):
# This project slug needs to exist in the ``all_projects`` fixture.
ho... | 30 | 1,037 |
ipython | IPython/lib/pretty.py | .py | """
Python advanced pretty printer. This pretty printer is intended to
replace the old `pprint` python module which does not allow developers
to provide their own pretty print callbacks.
This module is based on ruby's `prettyprint.rb` library by `Tanaka Akira`.
Example Usage
-------------
To directly print the rep... | 959 | 30,884 |
saleor | saleor/graphql/product/tests/queries/variants_where/shared.py | .py | PRODUCT_VARIANTS_WHERE_QUERY = """
query($where: ProductVariantWhereInput!, $channel: String) {
productVariants(first: 10, where: $where, channel: $channel) {
edges {
node {
id
name
sku
}
}
}
}
"""
| 14 | 290 |
biopython | Bio/ExPASy/Prodoc.py | .py | # Copyright 2000 by Jeffrey Chang. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Code to work with the prosite.doc file from Prosite.
See https://www.expasy.org/prosite/
... | 174 | 5,009 |
hatch | src/hatch/utils/structures.py | .py | from __future__ import annotations
import os
from fnmatch import fnmatch
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Collection, Mapping
from types import TracebackType
class EnvVars(dict):
def __init__(
self,
env_vars: Mapping | None = None,
in... | 49 | 1,349 |
openvino | tests/layer_tests/pytorch_tests/test_neg.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 neg_model(torch.nn.Module):
def forward(self, x):
return x * (-x.shape[-1])
class TestNeg(PytorchLayerTest):
def _prepare_input(s... | 30 | 906 |
openvino | src/bindings/python/src/openvino/properties/hint/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Enums
from openvino._pyopenvino.properties.hint import Priority
from openvino._pyopenvino.properties.hint import SchedulingCoreType
from openvino._pyopenvino.properties.hint import ModelDistributionPolicy
from o... | 16 | 608 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/quad_form_canon.py | .py | from cvxpy.atoms.affine.hstack import hstack
from cvxpy.atoms.log_sum_exp import log_sum_exp
def quad_form_canon(expr, args):
x = args[0]
P = args[1]
elems = []
for i in range(P.shape[0]):
for j in range(P.shape[0]):
elems.append(P[i, j] + x[i] + x[j])
return log_sum_exp(hstack... | 13 | 333 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_add.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasAdd(CommonTF2LayerTest):
def create_keras_add_net(self, input_names, input_shapes, input_type, ir_version):
"""... | 89 | 4,784 |
probability | tensorflow_probability/python/math/ode/xla_test.py | .py | # Copyright 2019 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... | 64 | 2,200 |
mlflow | dev/clint/src/clint/rules/isinstance_union_syntax.py | .py | import ast
from clint.rules.base import Rule
class IsinstanceUnionSyntax(Rule):
def _message(self) -> str:
return (
"Use `isinstance(obj, (X, Y))` instead of `isinstance(obj, X | Y)`. "
"The union syntax with `|` is slower than using a tuple of types."
)
@staticmethod... | 53 | 1,749 |
textual | docs/examples/widgets/toast.py | .py | from textual.app import App
class ToastApp(App[None]):
def on_mount(self) -> None:
# Show an information notification.
self.notify("It's an older code, sir, but it checks out.")
# Show a warning. Note that Textual's notification system allows
# for the use of Rich console markup.
... | 27 | 897 |
textual | docs/examples/styles/row_span.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Placeholder
class MyApp(App):
CSS_PATH = "row_span.tcss"
def compose(self):
yield Grid(
Placeholder(id="p1"),
Placeholder(id="p2"),
Placeholder(id="p3"),
Placeho... | 24 | 508 |
mlflow | mlflow/models/cli.py | .py | import logging
import click
from mlflow.mcp.decorator import mlflow_mcp
from mlflow.models import python_api
from mlflow.models.flavor_backend_registry import get_flavor_backend
from mlflow.models.model import update_model_requirements
from mlflow.utils import cli_args
from mlflow.utils import env_manager as _EnvMana... | 354 | 12,849 |
pymc | pymc/variational/operators.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... | 154 | 4,554 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/graph_optimizers/utils.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import itertools
from collections.abc import Sequence
from typing import... | 180 | 7,842 |
pyomo | pyomo/contrib/mindtpy/tests/test_mindtpy_solution_pool.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... | 141 | 5,383 |
black | tests/data/cases/python39.py | .py | @relaxed_decorator[0]
def f():
...
@relaxed_decorator[extremely_long_name_that_definitely_will_not_fit_on_one_line_of_standard_length]
def f():
...
@extremely_long_variable_name_that_doesnt_fit := complex.expression(with_long="arguments_value_that_wont_fit_at_the_end_of_the_line")
def f():
...
# output
... | 28 | 630 |
saleor | saleor/graphql/order/mutations/utils.py | .py | from typing import TYPE_CHECKING, NamedTuple, Union
import graphene
from django.conf import settings
from django.core.exceptions import ValidationError
from promise import Promise
from ....checkout.fetch import get_variant_channel_listing
from ....core.taxes import zero_money, zero_taxed_money
from ....core.utils imp... | 351 | 12,446 |
saleor | saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py | .py | import datetime
import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....giftcard import GiftCardEvents
from .....giftcard.error_codes import GiftCa... | 964 | 27,725 |
textual | tests/snapshot_tests/snapshot_apps/text_area_unfocus.py | .py | """Tests the rendering of the TextArea for all supported languages."""
from textual.app import App, ComposeResult
from textual.widgets import TextArea
class TextAreaUnfocusSnapshot(App):
AUTO_FOCUS = None
def compose(self) -> ComposeResult:
text_area = TextArea.code_editor()
text_area.cursor_... | 18 | 433 |
pyro | tests/distributions/test_delta.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase
import numpy as np
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_equal
class TestDelta(TestCase):
def setUp(self):
self.v = torch.tensor([... | 79 | 2,862 |
beam | learning/katas/python/Core Transforms/FlattenWith/FlattenWith/tests/test_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"); you may not... | 36 | 1,350 |
conda | conda/testing/notices/fixtures.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of pytest fixtures used in conda.notices tests."""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from ...base.constants import DEFAULTS_CHAN... | 49 | 1,394 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_unitialized_variablev2.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import tensorflow as tf
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
placeholder = tf.raw_ops.Placeholder(dtype=tf.float32, shape=[3, 2], name='x')
va... | 20 | 768 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/div_canon.py | .py | def div_canon(expr, args):
del expr
# x / y == x * y**(-1).
return args[0] - args[1], []
| 5 | 101 |
beam | sdks/python/apache_beam/typehints/batch_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... | 197 | 6,420 |
pyomo | examples/pyomobook/gdp-ch/scont2.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... | 25 | 786 |
wandb | wandb/integration/prodigy/prodigy.py | .py | """Prodigy integration for W&B.
User can upload Prodigy annotated datasets directly
from the local database to W&B in Tables format.
Example usage:
```python
import wandb
from wandb.integration.prodigy import upload_dataset
run = wandb.init(project="prodigy")
upload_dataset("name_of_dataset")
wandb.finish()
```
"""... | 285 | 11,131 |
mlflow | tests/gateway/test_provider_registry.py | .py | import pytest
from mlflow.exceptions import MlflowException
from mlflow.gateway.provider_registry import provider_registry
def test_registry_keys_returns_all_providers_by_default():
keys = provider_registry.keys()
assert len(keys) > 0
assert "openai" in keys
assert "anthropic" in keys
def test_regi... | 37 | 1,188 |
onnx | onnx/backend/test/case/node/neg.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Neg(Base):
@staticmethod
def export() -> None:
node = ... | 29 | 750 |
wagtail | wagtail/embeds/tests/test_rich_text.py | .py | from unittest.mock import patch
from django.test import TestCase, override_settings
from django.urls import reverse_lazy
from wagtail.embeds.exceptions import EmbedNotFoundException
from wagtail.embeds.models import Embed
from wagtail.embeds.rich_text import MediaEmbedHandler as FrontendMediaEmbedHandler
from wagtail... | 160 | 5,874 |
onnxruntime | tools/python/wgsl_template/test/golden_compare.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Shared helpers for comparing generated WGSL output against goldens.
Some details of the generated file set are host-dependent and NOT part
of the equivalence contract (see DESIGN_wgsl_python_port.md,
"Determinism"): ``__st... | 62 | 2,545 |
astropy | astropy/coordinates/tests/test_celestial_transformations.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from itertools import combinations
import numpy as np
import pytest
from astropy import units as u
from astropy.coordinates import (
CartesianDifferential,
CartesianRepresentation,
EarthLocation,
SkyCoord,
galactocentric_frame_defaul... | 432 | 15,354 |
pyomo | pyomo/contrib/community_detection/event_log.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... | 192 | 7,957 |
saleor | saleor/graphql/account/mutations/staff/utils.py | .py | CUSTOMER_UPDATE_FIELDS = {
"first_name",
"last_name",
"email",
"is_active",
"note",
"external_reference",
"is_confirmed",
"language_code",
"customer_type_id",
"metadata",
"private_metadata",
}
| 14 | 237 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.