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 |
|---|---|---|---|---|---|
sqlmap | lib/parse/banner.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from xml.sax.handler import ContentHandler
from lib.core.common import Backend
from lib.core.common import parseXmlFile
from lib.core.common import sanitizeStr
from li... | 121 | 3,895 |
sqlmap | thirdparty/six/__init__.py | .py | # Copyright (c) 2010-2024 Benjamin Peterson
#
# 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, copy, modify, merge, publi... | 1,004 | 34,703 |
wandb | wandb/integration/ultralytics/pose_utils.py | .py | from __future__ import annotations
from typing import Any
import numpy as np
from PIL import Image
from tqdm.auto import tqdm
from ultralytics.engine.results import Results
from ultralytics.models.yolo.pose import PosePredictor
from ultralytics.utils.plotting import Annotator
import wandb
from wandb.integration.ultr... | 106 | 3,729 |
probability | tensorflow_probability/python/experimental/mcmc/sharded.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 91 | 3,492 |
wagtail | wagtail/embeds/oembed_providers.py | .py | animoto = {
"endpoint": "https://animoto.com/services/oembed",
"urls": [
r"^https?://animoto\.com/play/.+$",
],
}
audioboom = {
"endpoint": "https://audioboom.com/publishing/oembed.{format}",
"urls": [
r"^https?://audioboom\.com/boos/.+$",
r"^https?://audioboom\.com/posts/.+... | 736 | 16,002 |
mkdocs-material | material/plugins/blog/structure/markdown.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... | 62 | 2,528 |
pyomo | examples/pyomobook/nonlinear-ch/disease_est/disease_estimation.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 71 | 2,138 |
scikit-bio | skbio/tree/tests/test_utils.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.
# --------------------------------------------... | 85 | 3,327 |
metrics | tests/unittests/audio/__init__.py | .py | import os
from typing import Callable, Optional
from torch import Tensor
from unittests import _PATH_ALL_TESTS
_SAMPLE_AUDIO_SPEECH = os.path.join(_PATH_ALL_TESTS, "_data", "audio", "audio_speech.wav")
_SAMPLE_AUDIO_SPEECH_BAB_DB = os.path.join(_PATH_ALL_TESTS, "_data", "audio", "audio_speech_bab_0dB.wav")
_SAMPLE_N... | 31 | 1,008 |
pyomo | examples/pyomobook/performance-ch/SparseSets.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... | 39 | 1,128 |
scikit-optimize | examples/ask-and-tell.py | .py | """
=======================
Async optimization Loop
=======================
Bayesian optimization is used to tune parameters for walking robots or other
experiments that are not a simple (expensive) function call.
Tim Head, February 2017.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
They often foll... | 146 | 5,108 |
ipython | IPython/core/prefilter.py | .py | """
Prefiltering components.
Prefilters transform user input before it is exec'd by Python. These
transforms are used to implement additional syntax such as !ls and %magic.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from keyword import iskeyword
import r... | 707 | 25,717 |
saleor | saleor/payment/gateways/stripe/tests/test_webhooks.py | .py | import json
import logging
from decimal import Decimal
from unittest.mock import Mock, patch
import pytest
from django.core.exceptions import ValidationError
from django.utils import timezone
from stripe.stripe_object import StripeObject
from .....checkout.calculations import calculate_checkout_total_with_gift_cards
... | 1,813 | 57,053 |
beam | sdks/python/apache_beam/examples/inference/online_clustering/clustering_pipeline/pipeline/transformations.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... | 198 | 7,440 |
onnx | onnx/backend/test/case/node/sqrt.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 Sqrt(Base):
@staticmethod
def export() -> None:
node =... | 29 | 758 |
biopython | Bio/Align/hhr.py | .py | # Copyright 2022 by Michiel de Hoon. 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 fo... | 237 | 9,503 |
beam | sdks/python/apache_beam/runners/interactive/options/capture_control_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... | 178 | 7,209 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/__init__.py | .py | from .fusion import Fusion # noqa: F401
from .fusion_gelu import FusionGelu # noqa: F401
from .fusion_layernorm import FusionLayerNormalization # noqa: F401
from .replace_upsample_with_resize import ReplaceUpsampleWithResize # noqa: F401
| 5 | 242 |
beam | sdks/python/apache_beam/ml/__init__.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... | 21 | 908 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_exp.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# exp paddle model generator
#
import paddle
import numpy as np
from save_model import saveModel
import sys
def exp(name: str, x):
import paddle
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Prog... | 47 | 1,228 |
mlflow | tests/pyfunc/test_pyfunc_input_converter.py | .py | from dataclasses import asdict, dataclass
from typing import Optional
import pandas as pd
import pytest
from mlflow.models.rag_signatures import ChatCompletionRequest
from mlflow.pyfunc.utils.input_converter import _hydrate_dataclass
def test_hydrate_dataclass_input_no_dataclass():
# Define a class that is not ... | 90 | 2,529 |
mlflow | tests/entities/test_assessment_source.py | .py | import pytest
from mlflow.entities.assessment_source import AssessmentSource
from mlflow.exceptions import MlflowException
def test_assessment_source_equality():
source1 = AssessmentSource(source_type="HUMAN", source_id="user_1")
source2 = AssessmentSource(source_type="HUMAN", source_id="user_1")
source3... | 77 | 2,929 |
textual | tests/utilities/render.py | .py | import io
import re
from rich.console import Console, RenderableType
re_link_ids = re.compile(r"id=[\d\.\-]*?;.*?\x1b")
def replace_link_ids(render: str) -> str:
"""Link IDs have a random ID and system path which is a problem for
reproducible tests.
"""
return re_link_ids.sub("id=0;foo\x1b", render)... | 24 | 669 |
probability | tensorflow_probability/python/optimizer/convergence_criteria/__init__.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... | 30 | 1,359 |
astropy | astropy/units/format/generic_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/units
#
# You can then commit the changes... | 21 | 1,450 |
astropy | astropy/table/table.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import itertools
import sys
import types
import warnings
import weakref
from collections import OrderedDict, defaultdict
from collections.abc import Mapping
from copy import deepcopy
from pathlib import Path
from typing import Any
import numpy as np
from ... | 4,437 | 161,389 |
openvino | tests/layer_tests/pytorch_tests/test_copy.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestCopy(PytorchLayerTest):
def _prepare_input(self):
import numpy as np
return (self.random.randn(1, 3, 224, 224),)
de... | 69 | 2,129 |
onnxruntime | tools/python/wgsl_template/parser.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""PASS1: comment stripping, #include expansion, #define substitution.
Three sub-passes run in order on each top-level template:
1. :func:`_strip_comments` — replace ``//`` and ``/* */`` regions with
empty text while pres... | 353 | 13,564 |
onnx | onnx/reference/ops/op_col2im.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
from onnx.reference.ops._op_common_indices import _get_indices, _is_out
def _col2im_shape_check_2d(X, output_shape, kernel_shape, dilations, ... | 214 | 7,976 |
saleor | saleor/graphql/csv/enums.py | .py | from typing import Final
import graphene
from ...csv import ExportEvents, FileTypes
from ..core.doc_category import DOC_CATEGORY_PRODUCTS
from ..core.enums import to_enum
from ..core.types import BaseEnum
ExportEventEnum: Final[graphene.Enum] = to_enum(ExportEvents)
FileTypeEnum: Final[graphene.Enum] = to_enum(FileT... | 51 | 1,687 |
gunicorn | gunicorn/ctl/protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Socket Protocol
JSON-based protocol with length-prefixed framing for the control interface.
Message Format:
+----------------+------------------+
| Length (4B BE) | JSON Payload |
+---... | 225 | 5,705 |
onnx | onnx/reference/ops/op_where.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class Where(OpRun):
def _run(self, condition, x, y):
if (
x.dtype not in (y.dtype, object)
and x.dtype.ty... | 22 | 577 |
probability | tensorflow_probability/python/experimental/fastgp/fast_gp_test.py | .py | # Copyright 2024 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... | 826 | 26,518 |
conda | conda/common/path/python.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Common Python specific path utilities."""
from __future__ import annotations
import keyword
import re
from logging import getLogger
from os.path import join, split, splitext
from ..compat import on_win
log = getLogger(__name__)
def is_v... | 157 | 5,449 |
biopython | Bio/PDB/AbstractPropertyMap.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
#
# 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.
"""Class that maps (... | 131 | 4,080 |
pyomo | pyomo/common/_common.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... | 41 | 1,378 |
wandb | tests/unit_tests/test_registries/test_utils.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING
from pytest import fixture, mark, param, raises
from wandb.apis.public.registries._utils import (
prepare_artifact_types_input,
prepare_registry_filter,
)
from wandb.apis.public.registries.registries_search import Collections, Reg... | 201 | 6,004 |
confluent-kafka-python | tests/oauthbearer/aws/test_sasl_extensions_parser.py | .py | # Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 87 | 2,383 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS17/tensor_transformation.py | .py | # Copyright (c) 2023, 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 typing import List
from coremltools.converters.mil.mil import types
from coremltools.converters... | 620 | 20,501 |
openvino | src/plugins/intel_cpu/tools/dump_check/dump_check.py | .py | #!/usr/bin/python3
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Core, Model, Tensor, PartialShape, Type
from openvino import opset8 as opset
from openvino.op import Constant, Parameter, tensor_iterator
from openvino.passes import Manager, Serialize
from openvi... | 423 | 15,339 |
mlflow | dev/clint/tests/test_index.py | .py | from pathlib import Path
from unittest.mock import patch
from clint.index import SymbolIndex
def test_symbol_index_build_basic(tmp_path: Path) -> None:
mlflow_dir = tmp_path / "mlflow"
mlflow_dir.mkdir()
test_file = mlflow_dir / "test.py"
test_file.write_text("def test_function(): pass")
mock_g... | 43 | 1,401 |
mlflow | mlflow/agent/setup/cli.py | .py | from __future__ import annotations
import socket
import subprocess
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from urllib.parse import urlparse
import click
from mlflow.agent.agents import AGENTS, AgentName, AgentTool, detect_installed, get_agent
from mlflow.agent.se... | 365 | 13,229 |
saleor | saleor/graphql/discount/tests/deprecated/test_voucher_update.py | .py | import json
from unittest.mock import call, patch
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....discount import DiscountValueType
from .....discount.error_codes import DiscountErrorCode
fro... | 146 | 5,006 |
pyomo | pyomo/contrib/piecewise/tests/test_outer_repn_gdp.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... | 184 | 7,697 |
wagtail | wagtail/admin/apps.py | .py | import swapper
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
from . import checks # NOQA: F401
class WagtailAdminAppConfig(AppConfig):
name = "wagtail.admin"
label = "wagtailadmin"
verbose_name = _("Wagtail admin")
default_auto_field = "django.db.models.Aut... | 25 | 833 |
onnxruntime | onnxruntime/test/python/transformers/test_convert_tf_models_to_pytorch.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.
# -------------------------------------------------------------... | 62 | 2,309 |
pyomo | pyomo/core/tests/data/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 12 | 570 |
scikit-bio | skbio/alignment/tests/test_path.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.
# --------------------------------------------... | 815 | 34,055 |
saleor | saleor/graphql/core/tests/test_validators.py | .py | import datetime
from decimal import Decimal
import pytest
from django.core.exceptions import ValidationError
from django.utils import timezone
from graphql.error import GraphQLError
from ....product.models import Category
from ..validators import (
clean_seo_fields,
validate_end_is_after_start,
validate_o... | 186 | 5,283 |
onnxruntime | orttraining/orttraining/python/training/utils/hooks/__init__.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import torch
__all__ = [
"GlobalSubscriberManager",
"Statistic... | 38 | 1,388 |
hatch | backend/src/hatchling/utils/context.py | .py | from __future__ import annotations
import os
import string
from abc import ABC, abstractmethod
from collections import ChainMap
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from hatchling.utils.fs import path_to_uri
if TYPE_CHECKING:
from collections.abc import Iterable, Iterator, ... | 176 | 6,109 |
pdm | src/pdm/models/finder.py | .py | from __future__ import annotations
import logging
from collections.abc import Callable
from typing import TYPE_CHECKING, Any
import unearth
from dep_logic.specifiers import InvalidSpecifier, parse_version_specifier
from packaging.version import Version
from unearth.evaluator import Evaluator, FormatControl, LinkMisma... | 115 | 4,003 |
cvxpy | cvxpy/reductions/solvers/conic_solvers/cuopt_conif.py | .py | """
Copyright 2025 NVIDIA CORPORATION
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, soft... | 517 | 19,373 |
hatch | src/hatch/env/collectors/custom.py | .py | from __future__ import annotations
import os
from typing import Any
from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface
from hatch.plugin.constants import DEFAULT_CUSTOM_SCRIPT
from hatch.plugin.utils import load_plugin_from_script
class CustomEnvironmentCollector:
PLUGIN_NAME = "cus... | 44 | 1,475 |
saleor | saleor/graphql/giftcard/tests/bulk_mutations/test_gift_card_bulk_delete.py | .py | from unittest import mock
import graphene
from .....giftcard.models import GiftCard
from ....tests.utils import assert_no_permission, get_graphql_content
GIFT_CARD_BULK_DELETE_MUTATION = """
mutation GiftCardBulkDelete($ids: [ID!]!) {
giftCardBulkDelete(ids: $ids) {
count
errors {... | 128 | 3,489 |
metrics | src/torchmetrics/functional/regression/tweedie_deviance.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... | 142 | 6,071 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_vae.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_attention_vae import FusionA... | 43 | 1,471 |
metrics | tests/unittests/classification/test_recall_fixed_precision.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... | 472 | 20,997 |
astropy | astropy/time/tests/test_functions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from astropy.time import Time, TimeDelta
class TestFunctionsTime:
def setup_class(cls):
cls.t = Time(50000, np.arange(8).reshape(4, 2), format="mjd", scale="tai")
def check(self, func, cls=None, scale=N... | 59 | 1,881 |
saleor | saleor/graphql/product/tests/deprecated/test_product.py | .py | import warnings
import graphene
from .....channel.models import Channel
from .....channel.utils import DEPRECATION_WARNING_MESSAGE
from .....product.models import Collection, CollectionChannelListing, Product
from .....tests.utils import dummy_editorjs
from ....tests.utils import get_graphql_content
QUERY_PRODUCT = ... | 387 | 12,453 |
beam | sdks/python/apache_beam/runners/interactive/display/pcoll_visualization.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... | 540 | 21,425 |
mlflow | tests/openai/test_openai_agent_autolog.py | .py | import asyncio
import copy
import gc
import json
from unittest import mock
import openai
import pytest
try:
import agents # noqa: F401
except ImportError:
pytest.skip("OpenAI SDK is not installed. Skipping tests.", allow_module_level=True)
from agents import Agent, Runner, function_tool, set_default_openai_... | 646 | 20,725 |
cvxpy | cvxpy/atoms/elementwise/entr.py | .py | """
Copyright 2013 Steven Diamond, Eric Chu
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... | 100 | 2,839 |
wandb | wandb/__main__.py | .py | from wandb.cli import cli
cli.cli(prog_name="python -m wandb")
| 4 | 64 |
django-cms | cms/test_utils/project/pluginapp/plugins/manytomany_rel/models.py | .py | from django.db import models
from cms.models import CMSPlugin
class Article(models.Model):
title = models.CharField(max_length=50)
section = models.ForeignKey('Section', on_delete=models.CASCADE)
def __str__(self):
return f"{self.title} -- {self.section}"
class Section(models.Model):
name ... | 57 | 1,474 |
attrs | tests/test_validators.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr.validators`.
"""
import re
import sys
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
... | 1,405 | 37,771 |
beam | sdks/python/apache_beam/ml/gcp/visionml_test.py | .py | # pylint: skip-file
#
# 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 "Licen... | 251 | 9,300 |
notebook | notebook/__main__.py | .py | """CLI entry point for notebook."""
import sys
from notebook.app import main
sys.exit(main()) # type:ignore[no-untyped-call]
| 8 | 129 |
saleor | saleor/attribute/models/page.py | .py | from django.contrib.postgres.indexes import BTreeIndex
from django.db import models
from ...core.models import SortableModel
from ...page.models import Page, PageType
from .base import AssociatedAttributeManager
class AssignedPageAttributeValue(SortableModel):
value = models.ForeignKey(
"AttributeValue",... | 49 | 1,384 |
hatch | src/hatch/utils/runner.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Sequence
from hatch.env.plugin.interface import EnvironmentInterface
class ExecutionContext:
def __init__(
self,
environment: EnvironmentInterface,
*,
s... | 84 | 2,617 |
kafka | tests/kafkatest/tests/streams/streams_relational_smoke_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 ... | 140 | 6,628 |
sphinx | sphinx/writers/manpage.py | .py | """Manual page writer, extended for Sphinx custom nodes."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from docutils import nodes
from docutils.writers import manpage
from sphinx import addnodes
from sphinx.locale import _, admonitionlabels
from sphinx.util import logging
from sphinx.... | 472 | 15,751 |
wagtail | wagtail/contrib/frontend_cache/utils.py | .py | import logging
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import import_string
logger = logging.getLogger("wagtail.frontendcache")
class InvalidFrontendCacheBackendError(ImproperlyConfigured):
pass
def get_backends(backend_settings... | 234 | 9,412 |
qutip | qutip/core/data/constant.py | .py | # This module exists to supply a couple of very standard constant matrices
# which are used in the data layer, and within `Qobj` itself. Other matrices
# (e.g. `create`) should not be here, but should be defined within the
# higher-level components of QuTiP instead.
from . import csr, dense, dia
from .csr import CSR
... | 137 | 3,807 |
wagtail | wagtail/test/headless_urls.py | .py | """An alternative urlconf module where Wagtail does not serve front-end URLs"""
from django.urls import include, path
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.images import urls as wagtailimages_urls
urlpatterns = [
path("admin/", inc... | 14 | 449 |
luigi | test/contrib/gcs_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015 Twitter 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 ... | 280 | 11,597 |
django-cms | cms/test_utils/project/sampleapp/urls_childapp.py | .py | from django.urls import re_path
from cms.test_utils.project.sampleapp import views
urlpatterns = [
re_path(r'^(?P<path>.+)$', views.childapp_view, name='childapp_view'),
]
| 8 | 178 |
conda | conda/gateways/connection/session.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Requests session configured with all accepted scheme adapters."""
from __future__ import annotations
from fnmatch import fnmatch
from functools import cache
from logging import getLogger
from threading import local
from typing import TYPE_C... | 440 | 14,781 |
probability | tensorflow_probability/python/distributions/joint_distribution_auto_batched.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... | 691 | 28,892 |
python-prompt-toolkit | src/prompt_toolkit/contrib/ssh/server.py | .py | """
Utility for running a prompt_toolkit application in an asyncssh server.
"""
from __future__ import annotations
import asyncio
import traceback
from asyncio import get_running_loop
from collections.abc import Callable, Coroutine
from typing import Any, TextIO, cast
import asyncssh
from prompt_toolkit.application... | 180 | 6,157 |
readthedocs.org | readthedocs/oauth/views.py | .py | import hmac
import structlog
from django.conf import settings
from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.views import APIView
from readthedocs.api.v2.views.integrations import GITHUB_EVENT_HEADER
from readthedocs.api.v2.views.integrations imp... | 78 | 2,926 |
wagtail | wagtail/snippets/blocks.py | .py | from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
from wagtail.blocks import ChooserBlock
from wagtail.coreutils import resolve_model_string
class SnippetChooserBlock(ChooserBlock):
# Blocks are instantiated before models are loaded, so we can't set
#... | 47 | 1,753 |
sqlmap | plugins/dbms/oracle/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
try:
import oracledb
except ImportError:
pass
import logging
import os
from lib.core.common import getSafeExString
from lib.core.convert import getText
from lib.core.dat... | 86 | 2,690 |
saleor | saleor/graphql/product/tests/test_variant_channel_listing_update.py | .py | from unittest.mock import patch
import graphene
import pytest
from ....product.error_codes import ProductErrorCode
from ....product.models import ProductChannelListing
from ...tests.utils import (
assert_negative_positive_decimal_value,
assert_no_permission,
get_graphql_content,
)
PRODUCT_VARIANT_CHANNEL... | 658 | 21,724 |
onnx | onnx/backend/test/case/node/softsign.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 Softsign(Base):
@staticmethod
def export() -> None:
no... | 29 | 777 |
wagtail | wagtail/documents/api/admin/views.py | .py | from ..v2.views import DocumentsAPIViewSet
class DocumentsAdminAPIViewSet(DocumentsAPIViewSet):
pass
| 6 | 107 |
beam | sdks/python/apache_beam/typehints/row_type.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... | 257 | 9,451 |
wandb | tests/system_tests/test_functional/asyncio_compat_run/test_asyncio_compat_run.py | .py | import pathlib
import signal
import subprocess
def test_asyncio_compat_run_stops_on_keyboard_interrupt():
script = pathlib.Path(__file__).parent / "pass_if_cancelled.py"
proc = subprocess.Popen(
["python", str(script)],
stdout=subprocess.PIPE,
)
# Wait for process to enter the asyncio... | 18 | 463 |
coremltools | deps/protobuf/update_compatibility_version.py | .py | #!/usr/bin/env python
"""Compatibility tests between last released and the current version.
Usage: ./update_compatibility_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
Example: ./update_compatibility_version.py 3.7.1
"""
from __future__ import print_function
import re
import sys
if len(sys.argv) < 2 or len(sys.a... | 57 | 1,405 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script/jupyter_again.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
c = '''
title: "Quick test"
output:
ioslides_presentation:
widescreen: true
smaller: true
editor_options:
chunk_output_type console
'''
import yaml
print(yaml.dump(yaml.load(c)))
# ?next
| 23 | 316 |
luigi | luigi/tools/deps.py | .py | #!/usr/bin/env python
# Finds all tasks and task outputs on the dependency paths from the given downstream task T
# up to the given source/upstream task S (optional). If the upstream task is not given,
# all upstream tasks on all dependency paths of T will be returned.
# Terms:
# if the execution of Task T depends ... | 133 | 4,689 |
sqlmap | lib/request/kerberos.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
# Native, dependency-free HTTP "Negotiate" (SPNEGO/Kerberos) authentication, built on the in-tree
# pure-Python Kerberos client (extra/kerberos). No 'pykerberos'/'gssapi'/'request... | 100 | 5,187 |
mlflow | examples/llama_index/workflow/workflow/events.py | .py | from typing import Literal
from llama_index.core.schema import NodeWithScore
from llama_index.core.workflow import Event
class VectorSearchRetrieveEvent(Event):
"""Event for triggering VectorStore index retrieval step."""
query: str
class BM25RetrieveEvent(Event):
"""Event for triggering BM25 retrieva... | 48 | 1,000 |
saleor | saleor/warehouse/management.py | .py | import math
from collections import defaultdict
from collections.abc import Iterable
from functools import partial
from typing import TYPE_CHECKING, Any, NamedTuple, cast
from uuid import UUID
from django.db import transaction
from django.db.models import F, Sum
from django.db.models.expressions import Exists, OuterRe... | 1,078 | 39,533 |
beam | sdks/python/apache_beam/io/components/rate_limiter_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... | 182 | 6,673 |
saleor | saleor/graphql/discount/mutations/voucher/voucher_add_catalogues.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....discount.error_codes import DiscountErrorCode
from .....permission.enums import DiscountPermissions
from .....product.utils import get_products_ids_without_variants
from .....webhook.event_types import WebhookEventAsyncType
from ....core impo... | 129 | 4,768 |
clearml | clearml/utilities/pigar/__main__.py | .py | # -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import
import codecs
import os
from typing import Callable, Set, Optional, Tuple, List, Any
import six
from .log import logger
from .modules import ReqsModules
from .reqs import project_import_modules, is_std_or_local_lib, is_base_mod... | 217 | 8,897 |
hydra | examples/tutorials/basic/running_your_hydra_app/5_basic_sweep/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(f"driver={cfg.db.driver}, timeout={cfg.db.timeout}")
if __name__ == "__main__":
my_app()
| 14 | 316 |
beam | sdks/python/apache_beam/internal/cloudpickle_pickler.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... | 298 | 9,447 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from __future__ import annotations
import itertools
import logging
impo... | 1,645 | 68,593 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.