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/attribute/mutations/base_reorder_attributes.py | .py | from typing import TYPE_CHECKING
import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from ....core.tracing import traced_atomic_transaction
from ...core.inputs import ReorderInput
from ...core.mutations import BaseMutation
from ...core.utils.reordering import perform_reordering
from... | 171 | 5,537 |
wandb | wandb/automations/automations.py | .py | from __future__ import annotations
from datetime import datetime
from typing import Annotated
from pydantic import Field
from wandb._pydantic import GQLId, GQLInput
from ._generated import TriggerFields
from .actions import InputAction, SavedAction
from .events import InputEvent, SavedEvent
from .scopes import Auto... | 86 | 2,649 |
mkdocs | mkdocs/commands/gh_deploy.py | .py | from __future__ import annotations
import logging
import os
import re
import subprocess
from typing import TYPE_CHECKING
import ghp_import # type: ignore
from packaging import version
import mkdocs
from mkdocs.exceptions import Abort
if TYPE_CHECKING:
from mkdocs.config.defaults import MkDocsConfig
log = logg... | 170 | 5,231 |
clearml | clearml/storage/manager.py | .py | import fnmatch
import logging
import shutil
from multiprocessing.pool import ThreadPool
from random import random
from time import time
from typing import Iterator, List, Optional, Union
from six.moves.urllib.parse import quote
from pathlib2 import Path
from .cache import CacheManager
from .callbacks import ProgressR... | 633 | 27,931 |
gunicorn | gunicorn/instrument/statsd.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"Bare-bones implementation of statsD's protocol, client-side"
import logging
import socket
from re import sub
from gunicorn.glogging import Logger
# Instrumentation constants
METRIC_VAR = "metric"
VALUE_VAR = "v... | 141 | 4,969 |
ipython | tests/test_editorhooks.py | .py | """Test installing editor hooks"""
import sys
from unittest import mock
import pytest
from IPython import get_ipython
from IPython.core.error import TryNext
from IPython.lib import editorhooks
def test_install_editor():
called = []
def fake_popen(*args, **kwargs):
called.append(
{
... | 127 | 4,022 |
pdm | src/pdm/project/lockfile/__init__.py | .py | from __future__ import annotations
import sys
from pathlib import Path
from typing import TYPE_CHECKING
from pdm.project.lockfile.base import (
FLAG_CROSS_PLATFORM,
FLAG_DIRECT_MINIMAL_VERSIONS,
FLAG_INHERIT_METADATA,
FLAG_STATIC_URLS,
Lockfile,
)
from pdm.project.lockfile.pdmlock import PDMLock
f... | 59 | 1,477 |
sqlmap | extra/dbwire/clickhouse.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
"""
Minimal pure-python ClickHouse client over its native HTTP interface (stdlib only, no clickhouse_connect).
ClickHouse exposes an HTTP endpoint that runs a query in the reques... | 144 | 5,428 |
readthedocs.org | readthedocs/doc_builder/constants.py | .py | """Doc build constants."""
import re
import structlog
from django.conf import settings
log = structlog.get_logger(__name__)
PDF_RE = re.compile("Output written on (.*?)")
# Docker
DOCKER_SOCKET = settings.DOCKER_SOCKET
DOCKER_VERSION = settings.DOCKER_VERSION
DOCKER_IMAGE = settings.DOCKER_IMAGE
DOCKER_TIMEOUT_EX... | 29 | 513 |
django-cms | cms/tests/test_rendering.py | .py | from django.core.cache import cache
from django.http.response import Http404
from django.test.utils import override_settings
from django.urls import reverse
from sekizai.context import SekizaiContext
from cms import plugin_rendering
from cms.api import add_plugin, create_page
from cms.cache.placeholder import get_plac... | 983 | 41,611 |
beam | sdks/python/apache_beam/ml/rag/ingestion/qdrant_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... | 481 | 16,525 |
saleor | saleor/checkout/tests/test_cart.py | .py | import datetime
import pytest
from django.utils import timezone
from measurement.measures import Weight
from prices import Money, TaxedMoney
from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ...plugins.manager import get_plugins_manager
from ...product.models import Category
from .. import ... | 291 | 9,727 |
onnx | onnx/reference/reference_evaluator.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from io import BytesIO
from typing import Any
import numpy as np
import onnx
import onnx.model_container
from onnx.onnx_pb import (
FunctionProto,
GraphProto,
ModelProto,
NodeProto,
... | 618 | 24,519 |
mlflow | tests/langchain/sample_code/chain_with_mlflow_prompt.py | .py | from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
import mlflow
from mlflow.models import set_model
prompt = ChatPromptTemplate.from_template(
mlflow.load_prompt("prompts:/qa_prompt@production").to_single_brace_f... | 14 | 411 |
pyro | pyro/distributions/asymmetriclaplace.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
from torch.distributions import constraints
from torch.distributions.utils import broadcast_all, lazy_property
from .torch_distribution import TorchDistribution
class AsymmetricLaplace(TorchDistribution):
... | 211 | 7,369 |
pyomo | pyomo/contrib/solver/tests/solvers/test_highs.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... | 111 | 3,569 |
httpie | httpie/legacy/v3_1_0_session_cookie_format.py | .py | import argparse
from typing import Any, Type, List, Dict, TYPE_CHECKING
if TYPE_CHECKING:
from httpie.sessions import Session
INSECURE_COOKIE_JAR_WARNING = '''\
Outdated layout detected for the current session. Please consider updating it,
in order to not get affected by potential security problems.
For fixing ... | 101 | 2,905 |
metrics | src/torchmetrics/multimodal/lve.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... | 191 | 8,358 |
scikit-bio | skbio/tree/__init__.py | .py | r"""Trees and Phylogenetics (:mod:`skbio.tree`)
===========================================
.. currentmodule:: skbio.tree
This module provides functionality for working with trees, including phylogenetic trees
and various types of hierarchies with relevance in biology or beyond. It supports trees
that are multifurcat... | 630 | 19,655 |
clearml | clearml/backend_api/config/__init__.py | .py | from ...backend_config import Config
from pathlib2 import Path
def load(*additional_module_paths: str) -> Config:
"""
Load configuration with the API defaults, using the additional module path provided
:param additional_module_paths: Additional config paths for modules who'se default
configurations sh... | 16 | 535 |
metrics | src/torchmetrics/functional/nominal/__init__.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 35 | 1,285 |
jupyterlab | docs/source/_ext/typedoc_links.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
"""
Sphinx extension for TypeDoc cross-references.
Provides semantic roles for linking to TypeDoc-generated API documentation.
"""
import os
from collections.abc import Callable
from pathlib import Path
from typing im... | 157 | 5,019 |
wagtail | wagtail/admin/tests/test_rich_text_markdown.py | .py | from unittest.mock import patch
from django.core.files.base import ContentFile
from django.test import SimpleTestCase, TestCase
from draftjs_exporter import MarkdownParseError
from wagtail.admin.rich_text.converters.db_html import DbHTMLConverter
from wagtail.admin.rich_text.converters.markdown_db import MarkdownConv... | 335 | 13,773 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/logistic_canon.py | .py | """
Copyright 2013 Steven Diamond
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... | 35 | 1,209 |
black | tests/data/cases/split_delimiter_comments.py | .py | a = (
1 + # type: ignore
2 # type: ignore
)
a = (
1 # type: ignore
+ 2 # type: ignore
)
bad_split3 = (
"What if we have inline comments on " # First Comment
"each line of a bad split? In that " # Second Comment
"case, we should just leave it alone." # Third Comment
)
parametrize(
... | 52 | 817 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample_test.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");... | 69 | 2,385 |
saleor | saleor/tests/e2e/checkout/utils/checkout_delivery_method_update.py | .py | from ...account.utils.fragments import ADDRESS_FRAGMENT
from ...utils import get_graphql_content
CHECKOUT_DELIVERY_METHOD_UPDATE_MUTATION = (
"""
mutation checkoutDeliveryMethodUpdate($checkoutId: ID!, $deliveryMethodId: ID) {
checkoutDeliveryMethodUpdate(
id: $checkoutId
deliveryMethodId: $deliveryMetho... | 99 | 1,816 |
mlflow | tests/transformers/test_transformers_llm_inference_utils.py | .py | import uuid
from typing import Any, NamedTuple
from unittest import mock
import pandas as pd
import pytest
import torch
from mlflow.exceptions import MlflowException
from mlflow.models import infer_signature
from mlflow.transformers.llm_inference_utils import (
_get_default_task_for_llm_inference_task,
_get_f... | 314 | 10,571 |
wandb | wandb/sdk/launch/inputs/manage.py | .py | """Functions for declaring overridable configuration for launch jobs."""
from __future__ import annotations
from typing import Any
def manage_config_file(
path: str,
include: list[str] | None = None,
exclude: list[str] | None = None,
schema: Any | None = None,
):
r"""Declare an overridable confi... | 116 | 5,005 |
black | tests/data/cases/pattern_matching_case_case_small_line_length.py | .py | # flags: --minimum-version=3.10 --line-length=10
match test:
case case if True:
pass
# output
match test:
case (
case
) if True:
pass
| 14 | 173 |
readthedocs.org | readthedocs/projects/tasks/builds.py | .py | """
Tasks related to projects.
This includes fetching repository code, cleaning ``conf.py`` files, and
rebuilding documentation.
"""
import datetime
import os
import shutil
import signal
import socket
import subprocess
from dataclasses import dataclass
from dataclasses import field
from pathlib import Path
import st... | 1,050 | 43,268 |
onnxruntime | onnxruntime/python/tools/quantization/operators/concat.py | .py | import onnx
from ..quant_utils import ( # noqa: F401
TENSOR_NAME_QUANT_SUFFIX,
QuantizedValue,
QuantizedValueType,
attribute_to_kwarg,
ms_domain,
)
from .base_operator import QuantOperatorBase
from .qdq_base_operator import QDQOperatorBase # noqa: F401
class QLinearConcat(QuantOperatorBase):
... | 63 | 2,081 |
clearml | clearml/backend_api/services/v2_23/pipelines.py | .py | """
pipelines service
Provides a management API for pipelines in the system.
"""
from typing import List, Optional, Any
import six
from clearml.backend_api.session import Request, Response, schema_property
class StartPipelineRequest(Request):
"""
Start a pipeline
:param task: ID of the task on which the... | 159 | 4,837 |
gunicorn | examples/frameworks/django/testing/manage.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
#!/usr/bin/env python
import os, sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testing.settings")
from django.core.management import execute_from_command_line
execut... | 14 | 350 |
biopython | Bio/Align/mauve.py | .py | # Copyright 2015-2015 by Eric Rasche. 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.Align support f... | 254 | 10,056 |
pymc | pymc/logprob/transforms.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,169 | 34,646 |
coremltools | coremltools/converters/mil/frontend/tensorflow2/__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 ....._deps import _HAS_TF_2
if _HAS_TF_2:
# importing these causes all its imports to be re... | 14 | 455 |
onnxruntime | tools/python/check_onnx_model_mobile_usability.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This script is a stub that uses the model conversion script from the util subdirectory.
# We do it this way so we can use relative imports in that script, which makes it easy to include
# in the ORT p... | 12 | 488 |
readthedocs.org | readthedocs/analytics/models.py | .py | """Analytics modeling to help understand the projects on Read the Docs."""
import datetime
from collections import namedtuple
from urllib.parse import urlparse
from django.db import models
from django.db.models import Sum
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from r... | 212 | 7,334 |
astropy | astropy/units/function/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains classes and functions for defining and converting
between different function units and quantities, i.e., using units which
are some function of a physical unit, such as magnitudes and decibels.
"""
from . import core, logarit... | 18 | 505 |
beam | sdks/python/apache_beam/ml/gcp/recommendations_ai.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... | 599 | 20,000 |
readthedocs.org | readthedocs/organizations/urls/private.py | .py | """URLs that require login."""
from django.urls import path
from django.urls import re_path
from readthedocs.core.views import PageNotFoundView
from readthedocs.organizations.views import private as views
urlpatterns = [
path(
"",
views.ListOrganization.as_view(),
name="organization_list... | 97 | 2,920 |
textual | tests/test_line_filter.py | .py | from rich.segment import Segment
from rich.style import Style
from textual.color import Color
from textual.filter import DimFilter
def test_dim_apply():
"""Check dim filter changes color and resets dim attribute."""
dim_filter = DimFilter()
segments = [Segment("Hello, World!", Style.parse("dim #ffffff ... | 20 | 527 |
kafka | tests/kafkatest/tests/core/eligible_leader_replicas_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 use ... | 161 | 7,787 |
pyomo | pyomo/contrib/appsi/tests/test_fbbt.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... | 165 | 5,788 |
coremltools | coremltools/proto/ClassConfidenceThresholding_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: ClassConfidenceThresholding.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message a... | 42 | 1,826 |
mlflow | mlflow/genai/judges/prompts/tool_call_correctness.py | .py | import json
from typing import TYPE_CHECKING
from mlflow.genai.judges.utils.formatting_utils import (
format_available_tools,
format_tools_called,
)
from mlflow.genai.prompts.utils import format_prompt
if TYPE_CHECKING:
from mlflow.genai.utils.type import FunctionCall
from mlflow.types.chat import Cha... | 208 | 8,547 |
luigi | test/safe_extractor_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... | 126 | 4,483 |
beam | sdks/python/apache_beam/portability/utils.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... | 33 | 1,238 |
loguru | loguru/_asyncio_loop.py | .py | import asyncio
import sys
def load_loop_functions():
if sys.version_info >= (3, 7):
def get_task_loop(task):
return task.get_loop()
get_running_loop = asyncio.get_running_loop
else:
def get_task_loop(task):
return task._loop
def get_running_loop():
... | 28 | 597 |
cvxpy | cvxpy/tests/nlp_tests/stress_tests_diff_engine/test_multiply_sparse.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
... | 69 | 2,329 |
mlflow | mlflow/store/artifact/databricks_models_artifact_repo.py | .py | import json
import logging
import os
import posixpath
import mlflow.tracking
from mlflow.entities import FileInfo
from mlflow.environment_variables import (
MLFLOW_ENABLE_MULTIPART_DOWNLOAD,
MLFLOW_MULTIPART_DOWNLOAD_CHUNK_SIZE,
)
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 ... | 220 | 10,035 |
scikit-bio | skbio/alignment/tests/__init__.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.
# --------------------------------------------... | 8 | 353 |
attrs | typing_tests/mypy.py | .py | # SPDX-License-Identifier: MIT
"""
Typing examples that rely on Mypy-specific features (mostly the attrs plugin).
"""
from __future__ import annotations
import re
from typing import Any, Dict, List, Tuple
import attr
import attrs
# Typing via "type" Argument ---
@attr.s
class C:
a = attr.ib(type=int)
c =... | 429 | 8,241 |
sqlmap | plugins/dbms/extremedb/fingerprint.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.e... | 94 | 2,672 |
scikit-optimize | skopt/optimizer/optimizer.py | .py | import sys
import warnings
from math import log
from numbers import Number
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
from sklearn.base import clone
from sklearn.base import is_regressor
from joblib import Parallel, delayed
from sklearn.multioutput import MultiOutputRegressor
from sklearn.utils impor... | 677 | 27,738 |
pdm | src/pdm/formats/pylock.py | .py | from __future__ import annotations
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any
import tomlkit
from dep_logic.markers import AnyMarker, BaseMarker, MarkerUnion, parse_marker
from pdm.exceptions import ProjectError
from pdm.formats.base import make_array, make_inline_table
from pdm.model... | 170 | 7,323 |
metrics | tests/unittests/clustering/test_dunn_index.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... | 85 | 2,808 |
saleor | saleor/graphql/order/tests/mutations/test_fulfillment_refund_products.py | .py | from decimal import Decimal
from unittest import mock
from unittest.mock import ANY, patch
import graphene
from prices import Money, TaxedMoney
from .....core.prices import quantize_price
from .....order import FulfillmentLineData
from .....order.error_codes import OrderErrorCode
from .....order.fetch import OrderLin... | 1,068 | 39,883 |
pynacl | tests/test_sealed_box.py | .py | # Copyright 2013 Donald Stufft and individual contributors
#
# 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... | 162 | 4,714 |
pyomo | setup.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... | 318 | 11,955 |
saleor | saleor/order/tests/fixtures/order_line.py | .py | from decimal import Decimal
import pytest
from prices import Money, TaxedMoney
from ....discount import DiscountType
from ....warehouse.models import Allocation, Stock
from ... import OrderOrigin
from ...fetch import OrderLineInfo
from ...models import Order
@pytest.fixture
def order_line(order, variant):
produ... | 330 | 11,389 |
deap | deap/tools/selection.py | .py | import random
import numpy as np
from functools import partial
from operator import attrgetter
######################################
# Selections #
######################################
def selRandom(individuals, k):
"""Select *k* individuals at random from the input *individuals* with... | 327 | 13,325 |
beam | sdks/python/apache_beam/io/gcp/bigquery_io_metadata.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... | 94 | 3,452 |
mlflow | tests/server/auth/test_mcp_server_auth.py | .py | from typing import Any
import pytest
from mlflow.server.auth.__init__ import _permission_to_allowed_actions
from mlflow.server.auth.permissions import EDIT, MANAGE, NO_PERMISSIONS, READ, USE
# ---------------------------------------------------------------------------
# _permission_to_allowed_actions
# -------------... | 117 | 4,369 |
sphinx | tests/roots/test-ext-autodoc/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = ['sphinx.ext.autodoc']
autodoc_mock_imports = [
'dummy',
]
autodoc_type_aliases = {
'buffer_like': 'buffer_like',
'pathlike': 'pathlike',
'Handler': 'Handler',
}
nitpicky = True
| 19 | 294 |
hypercorn | src/hypercorn/asyncio/lifespan.py | .py | from __future__ import annotations
import asyncio
import sys
from collections.abc import Callable
from functools import partial
from typing import Any
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveEvent, ASGISendEvent, LifespanScope, LifespanState
from ..utils import LifespanFailureError, Li... | 124 | 4,401 |
mlflow | tests/assistant/providers/test_ollama_provider.py | .py | import json
from unittest.mock import MagicMock, patch
import pytest
from mlflow.assistant.providers import OllamaProvider, list_providers
from mlflow.assistant.providers.base import (
ProviderNotConfiguredError,
clear_config_cache,
)
def _ollama_provider():
for p in list_providers():
if p.name ... | 96 | 3,235 |
black | tests/data/cases/module_docstring_after_comment.py | .py | #!/python
# regression test for #4762
"""
docstring
"""
from __future__ import annotations
import os
# output
#!/python
# regression test for #4762
"""
docstring
"""
from __future__ import annotations
import os
| 22 | 217 |
jupytext | tests/functional/others/test_read_write_functions.py | .py | from io import StringIO
from pathlib import Path
import nbformat
from nbformat.v4.nbbase import new_markdown_cell, new_notebook
import jupytext
from jupytext.compare import compare, compare_notebooks
def test_simple_hook(tmpdir):
nb_file = str(tmpdir.join("notebook.ipynb"))
md_file = str(tmpdir.join("notebo... | 87 | 1,993 |
wagtail | wagtail/contrib/redirects/api/v3/router.py | .py | from datetime import datetime
from typing import Optional, cast
from django.http import Http404, HttpRequest
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from ninja import Field, Query, Router, Schema, Status
from ninja.pagination import paginate
from wagtail.actions.create... | 188 | 5,743 |
sphinx | sphinx/domains/c/_symbol.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.domains.c._ast import (
ASTDeclaration,
ASTNestedName,
)
from sphinx.locale import __
from sphinx.util import logging
if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import... | 740 | 27,196 |
sphinx | sphinx/search/hu.py | .py | """Hungarian search language."""
from __future__ import annotations
import snowballstemmer
from sphinx.search import SearchLanguage
from sphinx.search._stopwords.hu import HUNGARIAN_STOPWORDS
class SearchHungarian(SearchLanguage):
lang = 'hu'
language_name = 'Hungarian'
js_stemmer_rawcode = 'hungarian-... | 23 | 610 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyter_with_raw_cell_in_body.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
1+2+3
# region active=""
# This is a raw cell
# endregion
# This is a markdown cell
| 18 | 249 |
wandb | tests/unit_tests/test_file_stream.py | .py | import itertools
import os
import random
import string
from dataclasses import dataclass
from wandb import util
from wandb.sdk.internal.file_stream import CRDedupeFilePolicy
from wandb.sdk.lib.file_stream_utils import split_files
@dataclass
class Chunk:
data: str = None
def test_split_files():
def choices(... | 191 | 6,495 |
pyomo | examples/dae/laplace_BVP.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... | 109 | 2,496 |
wandb | tests/system_tests/test_artifacts/test_object_references.py | .py | from __future__ import annotations
import shutil
import time
from collections.abc import Callable
from contextlib import suppress
from pathlib import Path
from typing import Literal
import boto3
import botocore
import google.cloud.storage
import numpy as np
import wandb
from bokeh.plotting import figure
from pytest i... | 1,107 | 35,793 |
mlflow | tests/gateway/test_guardrail_utils.py | .py | import json
from unittest import mock
import pytest
from mlflow.entities.gateway_guardrail import (
GatewayGuardrail,
GatewayGuardrailConfig,
GuardrailAction,
GuardrailStage,
)
from mlflow.entities.scorer import ScorerVersion
from mlflow.gateway.guardrail_utils import (
load_guardrails,
run_po... | 356 | 12,676 |
pyro | tests/infer/reparam/test_discrete_cosine.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import DiscreteCosineReparam
from tests.common import assert_close
from .util i... | 137 | 4,030 |
mlflow | mlflow/utils/os.py | .py | import os
def is_windows():
"""
Returns true if the local system/OS name is Windows.
Returns:
True if the local system/OS name is Windows.
"""
return os.name == "nt"
| 13 | 198 |
saleor | saleor/site/tests/test_site_settings.py | .py | import pytest
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from ..models import SiteSettings
def test_new_get_current():
result = Site.objects.get_current()
assert result.name == "example.com"
assert result.domain == "example.com"
assert type(re... | 22 | 703 |
mamba | micromamba/tests/test_info.py | .py | import os
import pytest
from . import helpers
@pytest.mark.parametrize("prefix_selection", [None, "prefix", "name"])
def test_base(tmp_home, tmp_root_prefix, prefix_selection, monkeypatch):
monkeypatch.setenv("CONDA_PREFIX", str(tmp_root_prefix))
if prefix_selection == "prefix":
infos = helpers.inf... | 171 | 6,193 |
coveragepy | tests/test_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
"""Tests for the sys.monitoring core in coverage/sysmon.py."""
from __future__ import annotations
from unittest import mock
import pytest
from coverage import... | 77 | 2,986 |
beam | sdks/python/apache_beam/io/gcp/bigquery_avro_tools_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... | 113 | 4,519 |
mlflow | tests/utils/test_process_utils.py | .py | import os
import uuid
import pytest
from mlflow.utils.os import is_windows
from mlflow.utils.process import cache_return_value_per_process
@cache_return_value_per_process
def _gen_random_str1(v):
return str(v) + uuid.uuid4().hex
@cache_return_value_per_process
def _gen_random_str2(v):
return str(v) + uuid... | 67 | 1,931 |
python-prompt-toolkit | src/prompt_toolkit/cursor_shapes.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
from collections.abc import Callable
from enum import Enum
from typing import TYPE_CHECKING, Any
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.key_binding.vi_state import InputMode
if TYPE_CHECKING:
from .application import... | 119 | 3,736 |
saleor | saleor/webhook/transport/list_stored_payment_methods.py | .py | import logging
from typing import cast
import graphene
from django.core.cache import cache
from pydantic import ValidationError
from ...app.models import App
from ...payment.interface import (
JSONValue,
PaymentGateway,
PaymentGatewayInitializeTokenizationResponseData,
PaymentGatewayInitializeTokeniza... | 215 | 7,840 |
saleor | saleor/graphql/shop/mutations/shop_address_update.py | .py | import graphene
from ....account import models as account_models
from ....graphql.account.mixins import AddressMetadataMixin
from ....permission.enums import SitePermissions
from ...account.i18n import I18nMixin
from ...account.types import AddressInput
from ...core import ResolveInfo
from ...core.doc_category import ... | 52 | 1,920 |
gunicorn | gunicorn/ctl/cli.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
gunicornc - Gunicorn control interface CLI
Interactive and single-command modes for controlling Gunicorn instances.
"""
import argparse
import json
import os
import sys
from gunicorn.config import _get_defau... | 451 | 13,202 |
astropy | astropy/wcs/tests/extension/test_extension.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Build a small C extension against the public ``astropy.wcs`` C API.
The extension links against the headers published by ``astropy.wcs.get_include()``,
exactly as a downstream package such as drizzlepac does. It is used to check
that the members of th... | 184 | 6,011 |
jupytext | tests/functional/simple_notebooks/test_read_simple_clojure.py | .py | import jupytext
from jupytext.compare import compare
def test_read_simple_file(
script=""";; ---
;; title: Simple file
;; ---
;; Here we have some text
;; And below we have some code
((fn
[]
(println "Hello World")))
""",
):
nb = jupytext.reads(script, "clj")
assert len(nb.cells) == 3
assert nb.... | 34 | 760 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS18/test_tensor_transformation.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 itertools
import numpy as np
import pytest
from coremltools.converters.mil._deployment_compa... | 546 | 16,991 |
beam | sdks/python/apache_beam/examples/ml_transform/mltransform_one_hot_encoding_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... | 258 | 9,475 |
mlflow | tests/spark/autologging/datasource/test_spark_datasource_autologging.py | .py | import time
from unittest import mock
from pyspark.sql import Row
from pyspark.sql.types import IntegerType, StructField, StructType
import mlflow
import mlflow.spark
from mlflow.spark.autologging import _SPARK_TABLE_INFO_TAG_NAME
from mlflow.utils.validation import MAX_TAG_VAL_LENGTH
from tests.spark.autologging.ut... | 287 | 10,882 |
sqlmap | tests/test_sqlparse.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
SQL/string parsing helpers: field splitting and 0-depth (paren+quote aware)
scanning, query cleanup, regex extraction.
Includes regression cases for the quote-awareness bugs fixed pre... | 88 | 3,738 |
mlflow | tests/store/artifact/test_mlflow_artifact_repo.py | .py | import os
import posixpath
import threading
import time
from unittest import mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
from mlflow.store.artifact.mlflow_artifacts_repo import MlflowArtifactsRepository
from ml... | 595 | 20,724 |
black | tests/data/cases/pep_750_nested_quotes.py | .py | # flags: --minimum-version=3.14
# Regression test for t-strings whose replacement fields contain quotes.
# Normalising the outer quotes would escape the inner ones and produce a
# t-string that no longer parses, so these are left alone.
x = t'\'{a["b"]}\''
y = t'\'{"x"}\''
# The same applies when the replacement field ... | 35 | 1,279 |
onnxruntime | onnxruntime/test/testdata/if_mul.py | .py | from onnx import TensorProto, checker, helper, save, shape_inference
# if A: C = B * 2
# else: C = B * 3
if_then_branch = helper.make_graph(
nodes=[
helper.make_node(
"Mul",
inputs=["B", "ConstTwo"],
outputs=["if_output"],
name="mul_0",
),
],
... | 71 | 1,754 |
mlflow | examples/quickstart/mlflow_tracking.py | .py | import os
from random import randint, random
from mlflow import log_artifacts, log_metric, log_param
if __name__ == "__main__":
print("Running mlflow_tracking.py")
log_param("param1", randint(0, 100))
log_metric("foo", random())
log_metric("foo", random() + 1)
log_metric("foo", random() + 2)
... | 21 | 494 |
luigi | luigi/contrib/hdfs/clients.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... | 63 | 1,924 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.