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 |
|---|---|---|---|---|---|
python-prompt-toolkit | src/prompt_toolkit/completion/word_completer.py | .py | from __future__ import annotations
from collections.abc import Callable, Iterable, Mapping, Sequence
from re import Pattern
from prompt_toolkit.completion import CompleteEvent, Completer, Completion
from prompt_toolkit.document import Document
from prompt_toolkit.formatted_text import AnyFormattedText
__all__ = [
... | 96 | 3,458 |
textual | src/textual/css/scalar.py | .py | from __future__ import annotations
import re
from enum import Enum, unique
from fractions import Fraction
from functools import lru_cache
from typing import Iterable, NamedTuple
import rich.repr
from textual.geometry import Offset, Size, clamp
class ScalarError(Exception):
"""Base class for exceptions raised b... | 382 | 9,948 |
probability | tensorflow_probability/python/experimental/nn/layers_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... | 111 | 3,766 |
sqlmap | tamper/apostrophenullencode.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.enums import PRIORITY
__priority__ = PRIORITY.LOWEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces single quotes (') with an il... | 24 | 511 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_ReverseSequence.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
class TestReverseSequence(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'input:0' in inpu... | 105 | 5,115 |
saleor | saleor/graphql/core/types/sort_input.py | .py | import copy
import graphene
from graphene.types.inputobjecttype import InputObjectTypeOptions
from ..descriptions import DEPRECATED_IN_3X_INPUT
from ..enums import OrderDirection
from .base import BaseInputObjectType
class SortInputMeta(InputObjectTypeOptions):
sort_enum = None
class SortInputObjectType(BaseI... | 59 | 1,783 |
wandb | wandb/sdk/launch/environment/gcp_environment.py | .py | """Implementation of the GCP environment for wandb launch."""
from __future__ import annotations
import logging
import os
import subprocess
from wandb.sdk.launch.errors import LaunchError
from wandb.util import get_module
from ..utils import GCS_URI_RE, event_loop_thread_exec
from .abstract import AbstractEnvironme... | 336 | 12,709 |
mlflow | mlflow/utils/mlflow_tags.py | .py | """
File containing all of the run tags in the mlflow. namespace.
See the System Tags section in the MLflow Tracking documentation for information on the
meaning of these tags.
"""
MLFLOW_EXPERIMENT_SOURCE_ID = "mlflow.experiment.sourceId"
MLFLOW_EXPERIMENT_SOURCE_TYPE = "mlflow.experiment.sourceType"
MLFLOW_EXPERIME... | 159 | 7,118 |
saleor | saleor/graphql/product/tests/mutations/test_product_variant_update.py | .py | import datetime
import json
from unittest.mock import ANY, patch
from uuid import uuid4
import graphene
import pytest
from django.conf import settings
from django.utils.text import slugify
from measurement.measures import Weight
from .....attribute import AttributeInputType
from .....attribute.models import Attribute... | 4,230 | 139,045 |
metrics | src/torchmetrics/image/dists.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... | 137 | 5,725 |
mlflow | mlflow/entities/trace_metrics.py | .py | from dataclasses import dataclass
from enum import Enum
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.protos import service_pb2 as pb
class MetricViewType(str, Enum):
TRACES = "TRACES"
SPANS = "SPANS"
ASSESSMENTS = "ASSESSMENTS"
def __str__(self) -> str:
return self.va... | 98 | 2,979 |
sqlmap | lib/request/timeless.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
# HTTP/2 "timeless timing" oracle (Van Goethem et al., USENIX Security 2020) built on the native
# client's exchange_pair() primitive (lib/request/http2.py). Two requests are mult... | 993 | 62,219 |
lemur | lemur/tests/test_certificates.py | .py | import datetime
from flask import current_app
import json
import ssl
import threading
from http.server import HTTPServer, SimpleHTTPRequestHandler
from tempfile import NamedTemporaryFile
from unittest.mock import patch
import arrow
import pytest
from cryptography import x509
from cryptography.hazmat.backends import de... | 2,341 | 81,424 |
saleor | saleor/tests/e2e/checkout/test_checkout_switch_from_cc_to_standard_delivery_method.py | .py | import pytest
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permissions
from ..warehouse.utils import update_warehouse
from .utils import (
checkout_complete,
checkout_create,
checkout_delivery_method_up... | 120 | 3,730 |
pyro | pyro/poutine/runtime.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import functools
from typing import (
TYPE_CHECKING,
Callable,
Dict,
Generic,
List,
Optional,
Set,
Tuple,
TypeVar,
Union,
overload,
)
import torch
from typing_extensions import Literal, ... | 529 | 16,678 |
astropy | astropy/visualization/scripts/fits2bitmap.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from pathlib import Path
from astropy import log
from astropy.io.fits import getdata
from astropy.visualization.mpl_normalize import simple_norm
__all__ = ["fits2bitmap", "main"]
def fits2bitmap(
filename,
ext=0,
out_fn=None,
stretch="... | 249 | 7,602 |
saleor | saleor/webhook/transport/metrics.py | .py | from datetime import UTC, datetime
from urllib.parse import urlparse
from opentelemetry.semconv.attributes import error_attributes, server_attributes
from ...app.models import App
from ...core.models import EventDeliveryStatus
from ...core.telemetry import (
DEFAULT_DURATION_BUCKETS,
MetricType,
Scope,
... | 116 | 3,258 |
clearml | examples/frameworks/tensorflow/legacy/tensorboard_pr_curve.py | .py | # ClearML - Example of new tensorboard pr_curves model
#
# Copyright 2017 The TensorFlow 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.apach... | 242 | 9,625 |
omegaconf | tests/test_omegaconf.py | .py | import pathlib
import platform
from contextlib import nullcontext
from pathlib import Path
from typing import Any, Union
from pytest import mark, param, raises
from omegaconf import (
MISSING,
BooleanNode,
BytesNode,
DictConfig,
EnumNode,
FloatNode,
IntegerNode,
ListConfig,
Missing... | 810 | 24,829 |
sphinx | tests/roots/test-linkcheck-localserver-anchor/conf.py | .py | exclude_patterns = ['_build']
linkcheck_anchors = True
linkcheck_timeout = 0.25
| 4 | 80 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_lambda.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
def x2_fun(x):
return x + x
def x2_fun_shape(input_shape):
return input_shape
def x1_plus_x2(inputs):
x1 = inputs[0]
... | 86 | 2,766 |
textual | tests/test_widget.py | .py | from operator import attrgetter
import pytest
from textual import events
from textual._node_list import DuplicateIds
from textual.app import App, ComposeResult
from textual.containers import Container, Vertical
from textual.content import Content
from textual.css.errors import StyleValueError
from textual.css.query i... | 769 | 22,998 |
openvino | src/tests/test_utils/functional_test_utils/layer_tests_summary/analyze_confomance_fails.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import re
import sys
import shutil
import zipfile
import argparse
import openpyxl
from utils.conformance_utils import get_logger
from utils import constants
LOGS_ZIP_NAME = 'logs.zip'
NEW_LOG_DIR = 'ie_logs'
SW_PLUGINS = {'H... | 306 | 13,701 |
coremltools | coremltools/optimize/torch/quantization/__init__.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
"""
.. _coremltools_optimize_torch_qat:
Quantization refers to techniques for performing neural netw... | 57 | 1,991 |
astropy | astropy/coordinates/angles/angle_lextab.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file was automatically generated from ply. To re-generate this file,
# remove it from this folder, then build astropy and run the tests in-place:
#
# python setup.py build_ext --inplace
# pytest astropy/coordinates/angles
#
# You can then commi... | 21 | 4,304 |
biopython | Tests/test_NMR.py | .py | # Copyright 2019 by Sergio Valqui. All rights reserved.
# Adapted from Doc/examples/nmr/simplepredict.py by Robert Bussell, Jr
# 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... | 130 | 5,068 |
ipython | tests/bad_all.py | .py | """Module with bad __all__
To test https://github.com/ipython/ipython/issues/9678
"""
def evil():
pass
def puppies():
pass
__all__ = [
evil, # Bad
"puppies", # Good
]
| 19 | 192 |
kombu | kombu/transport/virtual/base.py | .py | """Virtual transport implementation.
Emulates the AMQ API for non-AMQ transports.
"""
from __future__ import annotations
import base64
import socket
import warnings
from array import array
from collections import OrderedDict, defaultdict, namedtuple
from itertools import count
from multiprocessing.util import Finali... | 1,047 | 34,797 |
mlflow | tests/genai/judges/test_judge_tool_get_span_performance_and_timing_report.py | .py | from mlflow.entities.span import Span
from mlflow.entities.trace import Trace
from mlflow.entities.trace_data import TraceData
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.genai.judges.tools.get_s... | 883 | 26,386 |
attrs | tests/test_pyright.py | .py | # SPDX-License-Identifier: MIT
from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
pytestmark = [
pytest.mark.skipif(
shutil.which("pyright") is None, reason="Requires pyright."
),
]
def parse_pyright_output(test_file: Path) -> se... | 148 | 3,565 |
beam | sdks/python/apache_beam/runners/runner.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... | 328 | 12,004 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_prior_box.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# prior_box paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def prior_box(name: str, input_data, image_data, attrs: dict):
import paddle
paddle.enable_static()
with paddle.static.p... | 142 | 5,874 |
probability | tensorflow_probability/python/bijectors/identity.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... | 86 | 2,296 |
beam | sdks/python/apache_beam/internal/test_data/module_2_modified.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... | 93 | 2,275 |
mlflow | mlflow/store/artifact/models_artifact_repo.py | .py | import logging
import os
import urllib.parse
from pathlib import Path
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.store.artifact.artifact_repo import ArtifactRepository
from mlflow.store.artifact.databricks_models_artifact_repo import DatabricksModelsArtifactRepository
from mlflow.store.art... | 272 | 11,464 |
saleor | saleor/graphql/account/mutations/staff/staff_delete.py | .py | import graphene
from .....account import models
from .....attribute.utils import delete_user_unique_attribute_values
from .....core.tracing import traced_atomic_transaction
from .....giftcard.utils import deactivate_assigned_gift_cards
from .....permission.enums import AccountPermissions
from .....webhook.event_types ... | 64 | 2,460 |
pyomo | pyomo/opt/base/error.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 | 772 |
readthedocs.org | readthedocs/rtd_tests/tests/test_project_querysets.py | .py | from datetime import timedelta
import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from readthedocs.organizations.models import Organization
from readthedocs.projects.constants import PRIVATE, P... | 290 | 10,044 |
saleor | saleor/graphql/account/mutations/authentication/deactivate_all_user_tokens.py | .py | from typing import cast
from django.utils.crypto import get_random_string
from .....account import models
from .....permission.auth_filters import AuthorizationFilters
from ....core import ResolveInfo
from ....core.doc_category import DOC_CATEGORY_AUTH
from ....core.mutations import BaseMutation
from ....core.types i... | 28 | 973 |
hatch | tests/cli/dep/test_hash.py | .py | import os
from hashlib import sha256
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_incompatible_environment(hatch, temp_dir, helpers, build_env_config):
project_name = "My.App"
with temp_dir.as_cwd()... | 132 | 3,849 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/qat.py | .py | import logging
import os
import onnx
import quantize
import utils
from model import create_training_artifacts, get_models
from train import train_model
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(filename)s:%(lineno)s:%(funcName)s::%(message)s",
)
if __name__ == "__main__":
logging.i... | 62 | 2,033 |
python-prompt-toolkit | tests/test_key_binding.py | .py | from __future__ import annotations
from contextlib import contextmanager
import pytest
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import set_app
from prompt_toolkit.input.defaults import create_pipe_input
from prompt_toolkit.key_binding.key_bindings import KeyBindings
... | 205 | 6,662 |
mlflow | dev/clint/src/clint/rules/unnamed_thread.py | .py | import ast
from clint.resolver import Resolver
from clint.rules.base import Rule
class UnnamedThread(Rule):
def _message(self) -> str:
return (
"`threading.Thread()` must be called with a `name` argument to improve debugging "
"and traceability of thread-related issues."
)... | 24 | 715 |
jupyterlab | jupyterlab/federated_labextensions.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from typing import Any
from jupyter_builder.federated_extensions import (
build_labextension as _build_labextension,
)
from jupyter_builder.federated_extensions import (
develop_labextension as _develop_labext... | 48 | 1,453 |
beam | sdks/python/apache_beam/runners/dataflow/internal/apiclient.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,274 | 52,027 |
readthedocs.org | readthedocs/telemetry/models.py | .py | """Telemetry models."""
from django.db import models
from django_extensions.db.models import TimeStampedModel
class BuildDataManager(models.Manager):
"""Manager for the BuildData model."""
def collect(self, build, data):
"""
Save the collected information from a build.
We fill other... | 121 | 3,726 |
wagtail | wagtail/documents/tests/test_bulk_actions/test_bulk_add_to_collection.py | .py | from django.contrib.auth.models import Group, Permission
from django.test import TestCase
from django.urls import reverse
from wagtail.documents import get_document_model
from wagtail.models import Collection
from wagtail.test.utils import WagtailTestUtils
Document = get_document_model()
class TestBulkAddDocumentsT... | 169 | 5,919 |
ipython | IPython/core/doctb.py | .py | from __future__ import annotations
import linecache
import sys
from collections.abc import Sequence
from types import TracebackType
from typing import TYPE_CHECKING, Any
from collections.abc import Callable
from pygments.token import Token
from IPython.utils.terminal import get_terminal_size
from .tbtools import (
... | 472 | 16,333 |
wagtail | wagtail/images/tests/test_transform.py | .py | from unittest import TestCase
from wagtail.images.image_operations import ImageTransform
from wagtail.images.rect import Rect, Vector
class TestTransform(TestCase):
def test_resize(self):
context = ImageTransform((640, 480))
resized = context.resize((320, 240))
vector = Vector(100, 200)
... | 61 | 1,818 |
wagtail | wagtail/admin/views/generic/base.py | .py | import warnings
from django.contrib.admin.utils import quote, unquote
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models import Q
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse, reverse_lazy
from django.utils.functional i... | 516 | 18,867 |
pyomo | pyomo/repn/beta/matrix.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... | 755 | 25,281 |
pyro | pyro/infer/autoguide/structured.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import OrderedDict, defaultdict
from contextlib import ExitStack
from operator import attrgetter
from types import SimpleNamespace
from typing import Callable, Dict, Optional, Union
import torch
from torch.distributio... | 377 | 16,329 |
beam | sdks/python/apache_beam/runners/portability/abstract_job_service.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... | 377 | 13,262 |
coremltools | deps/pybind11/tests/test_modules.py | .py | from __future__ import annotations
import builtins
import pytest
import env
from pybind11_tests import ConstructorStats
from pybind11_tests import modules as m
from pybind11_tests.modules import subsubmodule as ms
def test_nested_modules():
import pybind11_tests
assert pybind11_tests.__name__ == "pybind11... | 119 | 3,999 |
onnxruntime | tools/python/fix_long_lines.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import os
import pathlib
import shutil
import tempfile
from util import logger, run
_log = logger.get_logger("fix_long_lines", logging.INFO)
# look for long lines in the file, and if found r... | 134 | 4,156 |
probability | tensorflow_probability/python/distributions/joint_distribution_named_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... | 798 | 32,681 |
onnxruntime | tools/ci_build/reduce_op_kernels.py | .py | # !/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import argparse
import io
import re
import shutil
import sys
import typing
from pathlib import Path
import op_registration_utils
from logger import get_logger
# dir... | 356 | 14,384 |
onnxruntime | onnxruntime/test/python/quantization/test_quantizeblockwise_4bits.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 140 | 6,555 |
astropy | astropy/cosmology/_src/tests/parameter/test_descriptors.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology._src.parameter.descriptor`."""
from types import MappingProxyType
from typing import ClassVar
import pytest
from astropy.cosmology import Cosmology, Parameter
from astropy.cosmology._src.parameter import ParametersAtt... | 130 | 5,075 |
biopython | Bio/SearchIO/InterproscanIO/__init__.py | .py | # Copyright 2018 by Adhemar Zerlotini. 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.
"""Bio.SearchIO suppor... | 97 | 5,155 |
onnx | onnx/backend/test/case/node/loop.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def compute_loop_outputs(x, seq, trip_count):
fo... | 460 | 14,731 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Conv2DBackpropInput.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(475912)
class TestConv2DBackpropInput(CommonTFLayerTest):
def _prepare_in... | 69 | 3,145 |
returns | returns/primitives/types.py | .py | from typing import Any, Never, Self
from returns.primitives.exceptions import ImmutableStateError
class Immutable:
"""
Helper type for objects that should be immutable.
When applied, each instance becomes immutable.
Nothing can be added or deleted from it.
.. code:: pycon
:force:
>... | 47 | 1,243 |
loguru | tests/test_formatting.py | .py | import os
import re
import pytest
from loguru import logger
@pytest.mark.parametrize(
("format", "validator"),
[
("{name}", lambda r: r == "tests.test_formatting"),
("{time}", lambda r: re.fullmatch(r"\d+-\d+-\d+T\d+:\d+:\d+[.,]\d+[+-]\d{4}", r)),
("{elapsed}", lambda r: re.fullmatch... | 269 | 9,089 |
probability | tensorflow_probability/python/internal/slicing.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... | 228 | 9,417 |
gunicorn | examples/echo.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
#
# Example code from Eventlet sources
from gunicorn import __version__
def app(environ, start_response):
"""Simplest possible application object"""
if environ['REQUEST_METHOD'].upper() != 'POST':
... | 27 | 654 |
astropy | astropy/io/votable/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package reads and writes data formats used by the Virtual
Observatory (VO) initiative, particularly the VOTable XML format.
"""
from astropy import config as _config
from .exceptions import (
IOWarning,
UnimplementedWarning,
VOTableC... | 53 | 1,254 |
probability | tensorflow_probability/python/bijectors/masked_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... | 1,021 | 34,499 |
saleor | saleor/graphql/meta/tests/mutations/test_update_private_metadata.py | .py | import base64
import graphene
import pytest
from django.db import transaction
from .....checkout.models import Checkout
from .....core.error_codes import MetadataErrorCode
from .....core.models import ModelWithMetadata
from .....tests import race_condition
from ....tests.utils import assert_no_permission, get_graphql... | 328 | 9,201 |
probability | tensorflow_probability/python/mcmc/slice_sampler_kernel.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... | 609 | 23,797 |
wandb | wandb/sdk/launch/builder/context_manager.py | .py | import logging
import os
import shutil
import tempfile
from wandb.sdk.launch._project_spec import LaunchProject
from wandb.sdk.launch.builder.build import image_tag_from_dockerfile_and_source
from wandb.sdk.launch.errors import LaunchError
from wandb.sdk.launch.utils import get_current_python_version
from .build impo... | 235 | 9,593 |
hydra | examples/tutorials/structured_configs/3_config_groups/my_app_with_inheritance.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from omegaconf import MISSING, OmegaConf
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class DBConfig:
host: str = "localhost"
port: int = MISSING
driver: str = MISSING
@d... | 50 | 997 |
saleor | saleor/tests/e2e/warehouse/utils/update_warehouse.py | .py | from ...utils import get_graphql_content
WAREHOUSE_UPDATE_MUTATION = """
mutation updateWarehouse($id: ID! $input: WarehouseUpdateInput!) {
updateWarehouse(id: $id, input: $input) {
errors {
message
field
code
}
warehouse {
id
name
slug
clickAndCollectOption
... | 45 | 1,038 |
mkdocs-material | material/plugins/tags/plugin.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 314 | 10,602 |
pyomo | pyomo/contrib/ampl_function_demo/build.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... | 31 | 1,131 |
mlflow | tests/spark/test_spark_autologging_stop.py | .py | import logging
import threading
import time
from unittest.mock import MagicMock, patch
import pytest
import mlflow.spark.autologging as autologging_module
from mlflow.spark.autologging import _stop_listen_for_spark_activity
@pytest.fixture
def autolog_caplog(caplog):
# "mlflow" sets propagate=False, so its reco... | 107 | 3,690 |
beam | sdks/python/apache_beam/testing/load_tests/microbenchmarks_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... | 99 | 3,365 |
black | scripts/generate_schema.py | .py | import json
from typing import IO, Any
import click
import black
def generate_schema_from_click(
cmd: click.Command,
) -> dict[str, Any]:
result: dict[str, dict[str, Any]] = {}
for param in cmd.params:
if not isinstance(param, click.Option) or param.is_eager:
continue
assert... | 76 | 2,423 |
pyomo | examples/pyomobook/scripts-ch/warehouse_cuts.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... | 68 | 2,378 |
saleor | saleor/graphql/translations/tests/mutations/test_product_bulk_translate.py | .py | from unittest.mock import patch
import graphene
import pytest
from .....tests.utils import dummy_editorjs
from ....core.enums import LanguageCodeEnum, TranslationErrorCode
from ....tests.utils import get_graphql_content
from ...mutations import ProductBulkTranslate
PRODUCT_BULK_TRANSLATE_MUTATION = """
mutation ... | 413 | 13,468 |
clearml | examples/frameworks/lightgbm/lightgbm_example.py | .py | # ClearML - Example of LightGBM integration
#
import lightgbm as lgb
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.metrics import mean_squared_error
from clearml import Task
def main():
# Connecting ClearML with the current process,
# from here on everything is logged automatically
tas... | 105 | 2,775 |
pyomo | pyomo/_archive/chull.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 | 690 |
pyro | pyro/util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import numbers
import random
import sys
import timeit
import warnings
from collections import defaultdict
from contextlib import contextmanager
from itertools import zip_longest
from typing import (
TYPE_CHECKING,
... | 725 | 24,654 |
hydra | hydra/core/default_element.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
from dataclasses import dataclass, field
from textwrap import dedent
from typing import List, Optional, Pattern, Union
from omegaconf import AnyNode, DictConfig
from hydra.errors import ConfigCompositionException
_defaults_list_interpol... | 590 | 18,126 |
metrics | tests/unittests/_helpers/wrappers.py | .py | import os
from functools import wraps
from typing import Any, Callable, Optional
from urllib.error import HTTPError
import pytest
ALLOW_SKIP_IF_OUT_OF_MEMORY = os.getenv("ALLOW_SKIP_IF_OUT_OF_MEMORY", "0") == "1"
ALLOW_SKIP_IF_BAD_CONNECTION = os.getenv("ALLOW_SKIP_IF_BAD_CONNECTION", "0") == "1"
_ERROR_CONNECTION_ME... | 94 | 3,389 |
slimit | src/slimit/unicode_chars.py | .py | ###############################################################################
#
# Copyright (c) 2011 Ruslan Spivak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, inc... | 155 | 9,745 |
openvino | src/tests/test_utils/functional_test_utils/layer_tests_summary/highlight_tables.py | .py | import os
import re
import sys
import argparse
from utils.conformance_utils import get_logger
from pathlib import Path
import xml.etree.ElementTree as ET
from jinja2 import Environment, FileSystemLoader
logger = get_logger('HighlightTable')
OPSET_REPORT_NAME_RE = r'.*report_opset_\w*.xml'
API_REPORT_NAME_RE = r'.*... | 347 | 17,764 |
cvxpy | cvxpy/atoms/elementwise/loggamma.py | .py | """
Copyright 2021 the CVXPY 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 law or agreed to in writing, softw... | 41 | 1,483 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_pyomo.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... | 80 | 2,581 |
hydra | tests/__init__.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
def verify_hydra_pytest_plugin_not_installed() -> None:
try:
# This check can be removed in 1.1
import hydra_pytest_plugin # type: ignore
except ImportError:
hydra_pytest_plugin = None
if hydra_pytest_plugin ... | 17 | 466 |
pymc | tests/distributions/test_continuous.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... | 2,561 | 91,103 |
returns | tests/test_maybe/test_maybe_unwrap.py | .py | import pytest
from returns.maybe import Nothing, Some
from returns.primitives.exceptions import UnwrapFailedError
def test_unwrap_success():
"""Ensures that unwrap works for Some container."""
assert Some(5).unwrap() == 5
def test_unwrap_failure():
"""Ensures that unwrap works for Nothing container."""... | 16 | 396 |
saleor | saleor/graphql/account/bulk_mutations/customer_bulk_delete.py | .py | import graphene
from django.conf import settings
from ....account import models
from ....attribute.utils import delete_user_unique_attribute_values
from ....core.tracing import traced_atomic_transaction
from ....giftcard.utils import deactivate_assigned_gift_cards
from ....permission.enums import AccountPermissions
fr... | 73 | 2,871 |
django-cms | cms/test_utils/project/sampleapp/cms_config.py | .py | from cms.app_base import CMSAppConfig
from cms.test_utils.project.sampleapp.cms_wizards import sample_wizard
class SampleAppConfig(CMSAppConfig):
cms_enabled = True
cms_wizards = [sample_wizard]
| 8 | 205 |
clearml | examples/pipeline/full_tabular_data_process_pipeline_example.py | .py | from clearml import PipelineDecorator, Task
@PipelineDecorator.component(cache=True)
def create_dataset(source_url: str, project: str, dataset_name: str) -> str:
print("starting create_dataset")
from clearml import StorageManager, Dataset
import pandas as pd
local_file = StorageManager.get_local_copy(... | 185 | 6,248 |
wandb | tests/system_tests/test_functional/test_tensorboard/test_torch_tb.py | .py | """Based on the docs: https://pytorch.org/docs/stable/tensorboard.html#torch.utils.tensorboard.writer.SummaryWriter
This test is to check if the tensorboard data is being processed correctly and sent to W&B.
"""
import numpy as np
import pytest
import torch
import wandb
from torch.utils.tensorboard import SummaryWrit... | 190 | 7,225 |
pymc | pymc/model/core.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... | 2,719 | 102,189 |
returns | tests/test_future/test_future_container/test_future_units.py | .py | from collections.abc import Awaitable
from typing import Any
import pytest
from returns.future import Future, FutureResult
from returns.io import IO
@pytest.mark.anyio
async def test_inner_value(subtests):
"""Ensure that coroutine correct value is preserved for all units."""
containers: list[Awaitable[Any]]... | 25 | 851 |
mlflow | docs/api_reference/source/testcode_block.py | .py | """
Standalone script to extract code blocks marked with :test: from Python docstrings.
Uses AST to parse Python files and extract docstrings with test code blocks.
"""
import ast
import re
import subprocess
import textwrap
from pathlib import Path
_CODE_BLOCK_HEADER_REGEX = re.compile(r"^\.\.\s+code-block::\s*py(tho... | 212 | 7,011 |
confluent-kafka-python | src/confluent_kafka/_model/__init__.py | .py | # Copyright 2022 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... | 272 | 7,854 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.