instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Add docstrings that explain logic | from abc import ABC, abstractmethod
from itertools import islice
from operator import itemgetter
from threading import RLock
from typing import (
TYPE_CHECKING,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Sequence,
Tuple,
Union,
)
from ._ratio import ratio_resolve
from .align import... | --- +++ @@ -30,6 +30,7 @@
class LayoutRender(NamedTuple):
+ """An individual layout render."""
region: Region
render: List[List[Segment]]
@@ -40,12 +41,15 @@
class LayoutError(Exception):
+ """Layout related error."""
class NoSplitter(LayoutError):
+ """Requested splitter does not exis... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/layout.py |
Generate docstrings for exported functions | import sys
from typing import Optional, Tuple
if sys.version_info >= (3, 8):
from typing import Literal
else:
from pip._vendor.typing_extensions import Literal # pragma: no cover
from ._loop import loop_last
from .console import Console, ConsoleOptions, RenderableType, RenderResult
from .control import Cont... | --- +++ @@ -18,6 +18,12 @@
class LiveRender:
+ """Creates a renderable that may be updated.
+
+ Args:
+ renderable (RenderableType): Any renderable object.
+ style (StyleType, optional): An optional style to apply to the renderable. Defaults to "".
+ """
def __init__(
self,
@@... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/live_render.py |
Insert docstrings into my code | import re
from abc import ABC, abstractmethod
from typing import List, Union
from .text import Span, Text
def _combine_regex(*regexes: str) -> str:
return "|".join(regexes)
class Highlighter(ABC):
def __call__(self, text: Union[str, Text]) -> Text:
if isinstance(text, str):
highlight_t... | --- +++ @@ -6,12 +6,29 @@
def _combine_regex(*regexes: str) -> str:
+ """Combine a number of regexes in to a single regex.
+
+ Returns:
+ str: New regex with all regexes ORed together.
+ """
return "|".join(regexes)
class Highlighter(ABC):
+ """Abstract base class for highlighters."""
... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/highlighter.py |
Add minimal docstrings for each function | class AbstractProvider(object):
def identify(self, requirement_or_candidate):
raise NotImplementedError
def get_preference(
self,
identifier,
resolutions,
candidates,
information,
backtrack_causes,
):
raise NotImplementedError
def find_m... | --- +++ @@ -1,6 +1,12 @@ class AbstractProvider(object):
+ """Delegate class to provide the required interface for the resolver."""
def identify(self, requirement_or_candidate):
+ """Given a requirement, return an identifier for it.
+
+ This is used to identify a requirement, e.g. whether two re... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/resolvelib/providers.py |
Write Python docstrings for this snippet | import sys
import time
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Union
if sys.version_info >= (3, 8):
from typing import Final
else:
from pip._vendor.typing_extensions import Final # pragma: no cover
from .segment import ControlCode, ControlType, Segment
if TYPE_CHECKING:
from .c... | --- +++ @@ -52,6 +52,12 @@
class Control:
+ """A renderable that inserts a control code (non printable but may move cursor).
+
+ Args:
+ *codes (str): Positional arguments are either a :class:`~rich.segment.ControlType` enum or a
+ tuple of ControlType and an integer parameter
+ """
... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/control.py |
Create documentation for each function signature | import inspect
import os
import platform
import sys
import threading
import zlib
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from datetime import datetime
from functools import wraps
from getpass import getpass
from html import escape
from inspect import isclass
from itertools import is... | --- +++ @@ -114,6 +114,7 @@
class ConsoleDimensions(NamedTuple):
+ """Size of the terminal."""
width: int
"""The width of the console in 'cells'."""
@@ -123,6 +124,7 @@
@dataclass
class ConsoleOptions:
+ """Options for __rich_console__ method."""
size: ConsoleDimensions
"""Size of c... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/console.py |
Please document this code using docstrings | import sys
from threading import Event, RLock, Thread
from types import TracebackType
from typing import IO, Any, Callable, List, Optional, TextIO, Type, cast
from . import get_console
from .console import Console, ConsoleRenderable, RenderableType, RenderHook
from .control import Control
from .file_proxy import FileP... | --- +++ @@ -14,6 +14,7 @@
class _RefreshThread(Thread):
+ """A thread that calls refresh() at regular intervals."""
def __init__(self, live: "Live", refresh_per_second: float) -> None:
self.live = live
@@ -32,6 +33,20 @@
class Live(JupyterMixin, RenderHook):
+ """Renders an auto-updating l... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/live.py |
Create docstrings for API functions | from typing import Iterator, List, Optional, Tuple
from ._loop import loop_first, loop_last
from .console import Console, ConsoleOptions, RenderableType, RenderResult
from .jupyter import JupyterMixin
from .measure import Measurement
from .segment import Segment
from .style import Style, StyleStack, StyleType
from .st... | --- +++ @@ -10,6 +10,15 @@
class Tree(JupyterMixin):
+ """A renderable for a tree structure.
+
+ Args:
+ label (RenderableType): The renderable or str for the tree label.
+ style (StyleType, optional): Style of this tree. Defaults to "tree".
+ guide_style (StyleType, optional): Style of t... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/tree.py |
Create documentation for each function signature | import re
from functools import partial, reduce
from math import gcd
from operator import itemgetter
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Tuple,
Union,
)
from ._loop import loop_last
from ._pick import pick_bool
from ._wr... | --- +++ @@ -44,6 +44,7 @@
class Span(NamedTuple):
+ """A marked up region in some text."""
start: int
"""Span start index."""
@@ -59,6 +60,7 @@ return self.end > self.start
def split(self, offset: int) -> Tuple["Span", Optional["Span"]]:
+ """Split a span in to 2 from a given of... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/text.py |
Create docstrings for all classes and functions | from typing import cast, List, Optional, Tuple, TYPE_CHECKING, Union
if TYPE_CHECKING:
from .console import (
Console,
ConsoleOptions,
RenderableType,
RenderResult,
)
from .jupyter import JupyterMixin
from .measure import Measurement
from .style import Style
from .segment import... | --- +++ @@ -17,6 +17,18 @@
class Padding(JupyterMixin):
+ """Draw space around content.
+
+ Example:
+ >>> print(Padding("Hello", (2, 4), style="on blue"))
+
+ Args:
+ renderable (RenderableType): String or other renderable.
+ pad (Union[int, Tuple[int]]): Padding for top, right, botto... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/padding.py |
Add documentation for all methods | from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence
if TYPE_CHECKING:
from pip._vendor.rich.console import ConsoleRenderable
from . import get_console
from .segment import Segment
from .terminal_theme import DEFAULT_TERMINAL_THEME
if TYPE_CHECKING:
from pip._vendor.rich.console import Conso... | --- +++ @@ -16,6 +16,7 @@
class JupyterRenderable:
+ """A shim to write html to Jupyter notebook."""
def __init__(self, html: str, text: str) -> None:
self.html = html
@@ -33,6 +34,7 @@
class JupyterMixin:
+ """Add to an Rich renderable to make it render in Jupyter notebook."""
__sl... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/jupyter.py |
Add docstrings to incomplete code | import configparser
from typing import Dict, List, IO, Mapping, Optional
from .default_styles import DEFAULT_STYLES
from .style import Style, StyleType
class Theme:
styles: Dict[str, Style]
def __init__(
self, styles: Optional[Mapping[str, StyleType]] = None, inherit: bool = True
):
sel... | --- +++ @@ -6,6 +6,12 @@
class Theme:
+ """A container for style information, used by :class:`~rich.console.Console`.
+
+ Args:
+ styles (Dict[str, Style], optional): A mapping of style names on to styles. Defaults to None for a theme with no styles.
+ inherit (bool, optional): Inherit default s... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/theme.py |
Generate helpful docstrings for debugging | import collections
import itertools
import operator
from .providers import AbstractResolver
from .structs import DirectedGraph, IteratorMapping, build_iter_view
RequirementInformation = collections.namedtuple(
"RequirementInformation", ["requirement", "parent"]
)
class ResolverException(Exception):
class Requ... | --- +++ @@ -11,6 +11,11 @@
class ResolverException(Exception):
+ """A base class for all exceptions raised by this module.
+
+ Exceptions derived by this class should all be handled in this module. Any
+ bubbling pass the resolver should be treated as a bug.
+ """
class RequirementsConflicted(Resol... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers.py |
Add docstrings to meet PEP guidelines | from __future__ import absolute_import
import linecache
import os
import platform
import sys
from dataclasses import dataclass, field
from traceback import walk_tb
from types import ModuleType, TracebackType
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Sequence,
T... | --- +++ @@ -61,6 +61,31 @@ suppress: Iterable[Union[str, ModuleType]] = (),
max_frames: int = 100,
) -> Callable[[Type[BaseException], BaseException, Optional[TracebackType]], Any]:
+ """Install a rich traceback handler.
+
+ Once installed, any tracebacks will be printed with syntax highlighting and ric... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/traceback.py |
Document classes and their methods | from typing import TYPE_CHECKING, Optional
from .align import AlignMethod
from .box import ROUNDED, Box
from .cells import cell_len
from .jupyter import JupyterMixin
from .measure import Measurement, measure_renderables
from .padding import Padding, PaddingDimensions
from .segment import Segment
from .style import Sty... | --- +++ @@ -15,6 +15,25 @@
class Panel(JupyterMixin):
+ """A console renderable that draws a border around its contents.
+
+ Example:
+ >>> console.print(Panel("Hello, World!"))
+
+ Args:
+ renderable (RenderableType): A console renderable object.
+ box (Box, optional): A Box instance ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/panel.py |
Add docstrings to clarify complex logic | import builtins
import collections
import dataclasses
import inspect
import os
import sys
from array import array
from collections import Counter, UserDict, UserList, defaultdict, deque
from dataclasses import dataclass, fields, is_dataclass
from inspect import isclass
from itertools import islice
from types import Map... | --- +++ @@ -56,14 +56,24 @@
def _is_attr_object(obj: Any) -> bool:
+ """Check if an object was created with attrs module."""
return _has_attrs and _attr_module.has(type(obj))
def _get_attr_fields(obj: Any) -> Sequence["_attr_module.Attribute[Any]"]:
+ """Get fields for an attrs object."""
retur... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/pretty.py |
Create documentation strings for testing functions | import sys
from itertools import chain
from typing import TYPE_CHECKING, Iterable, Optional
if sys.version_info >= (3, 8):
from typing import Literal
else:
from pip._vendor.typing_extensions import Literal # pragma: no cover
from .constrain import Constrain
from .jupyter import JupyterMixin
from .measure imp... | --- +++ @@ -21,6 +21,20 @@
class Align(JupyterMixin):
+ """Align a renderable by adding spaces if necessary.
+
+ Args:
+ renderable (RenderableType): A console renderable.
+ align (AlignMethod): One of "left", "center", or "right""
+ style (StyleType, optional): An optional style to apply... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/align.py |
Create simple docstrings for beginners | import sys
from typing import TYPE_CHECKING, Iterable, List
if sys.version_info >= (3, 8):
from typing import Literal
else:
from pip._vendor.typing_extensions import Literal # pragma: no cover
from ._loop import loop_last
if TYPE_CHECKING:
from pip._vendor.rich.console import ConsoleOptions
class Box... | --- +++ @@ -14,6 +14,21 @@
class Box:
+ """Defines characters to render boxes.
+
+ ┌─┬┐ top
+ │ ││ head
+ ├─┼┤ head_row
+ │ ││ mid
+ ├─┼┤ row
+ ├─┼┤ foot_row
+ │ ││ foot
+ └─┴┘ bottom
+
+ Args:
+ box (str): Characters making up box.
+ ascii (bool, optional): True if this ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/box.py |
Add docstrings to incomplete code | import sys
from typing import TYPE_CHECKING, Optional, Union
from .jupyter import JupyterMixin
from .segment import Segment
from .style import Style
from ._emoji_codes import EMOJI
from ._emoji_replace import _emoji_replace
if sys.version_info >= (3, 8):
from typing import Literal
else:
from pip._vendor.typin... | --- +++ @@ -21,6 +21,7 @@
class NoEmoji(Exception):
+ """No emoji by that name."""
class Emoji(JupyterMixin):
@@ -34,6 +35,15 @@ style: Union[str, Style] = "none",
variant: Optional[EmojiVariant] = None,
) -> None:
+ """A single emoji character.
+
+ Args:
+ nam... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/emoji.py |
Create docstrings for each class method | import io
import sys
import typing
import warnings
from abc import ABC, abstractmethod
from collections import deque
from dataclasses import dataclass, field
from datetime import timedelta
from io import RawIOBase, UnsupportedOperation
from math import ceil
from mmap import mmap
from operator import length_hint
from os... | --- +++ @@ -61,6 +61,7 @@
class _TrackThread(Thread):
+ """A thread to periodically update progress."""
def __init__(self, progress: "Progress", task_id: "TaskID", update_period: float):
self.progress = progress
@@ -116,6 +117,27 @@ disable: bool = False,
show_speed: bool = True,
) -> I... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/progress.py |
Help me comply with documentation standards | import ctypes
import sys
from typing import Any
windll: Any = None
if sys.platform == "win32":
windll = ctypes.LibraryLoader(ctypes.WinDLL)
else:
raise ImportError(f"{__name__} can only be imported on Windows")
import time
from ctypes import Structure, byref, wintypes
from typing import IO, NamedTuple, Type, ... | --- +++ @@ -1,3 +1,7 @@+"""Light wrapper around the Win32 Console API - this module should only be imported on Windows
+
+The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
+"""
import ctypes
import sys
from typing import Any
@@ -26,12 +30,26 @@
cla... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/_win32_console.py |
Add docstrings to make code maintainable | import base64
import ctypes
import itertools
import os
import re
import ssl
import struct
import tempfile
from .bindings import CFConst, CoreFoundation, Security
# This regular expression is used to grab PEM data out of a PEM bundle.
_PEM_CERTS_RE = re.compile(
b"-----BEGIN CERTIFICATE-----\n(.*?)\n-----END CERTI... | --- +++ @@ -1,3 +1,12 @@+"""
+Low-level helpers for the SecureTransport bindings.
+
+These are Python functions that are not directly related to the high-level APIs
+but are necessary to get them to work. They include a whole bunch of low-level
+CoreFoundation messing about and memory management. The concerns in this m... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py |
Add professional docstrings to my codebase | import contextlib
import ctypes
import platform
import ssl
import typing
from ctypes import (
CDLL,
POINTER,
c_bool,
c_char_p,
c_int32,
c_long,
c_uint32,
c_ulong,
c_void_p,
)
from ctypes.util import find_library
from ._ssl_constants import _set_ssl_context_verify_mode
_mac_version ... | --- +++ @@ -27,6 +27,7 @@
def _load_cdll(name: str, macos10_16_path: str) -> CDLL:
+ """Loads a CDLL by name, falling back to known path on 10.16+"""
try:
# Big Sur is technically 11 but we use 10.16 due to the Big Sur
# beta being labeled as 10.16.
@@ -201,6 +202,9 @@
def _handle_osst... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/truststore/_macos.py |
Document this module using docstrings | from typing import cast, List, Optional, TYPE_CHECKING, Union
from ._spinners import SPINNERS
from .measure import Measurement
from .table import Table
from .text import Text
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, RenderResult, RenderableType
from .style import StyleType
class Spinn... | --- +++ @@ -11,6 +11,17 @@
class Spinner:
+ """A spinner animation.
+
+ Args:
+ name (str): Name of spinner (run python -m rich.spinner).
+ text (RenderableType, optional): A renderable to display at the right of the spinner (str or Text typically). Defaults to "".
+ style (StyleType, opt... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/spinner.py |
Fully document this Python code with docstrings |
import os
def is_appengine():
return is_local_appengine() or is_prod_appengine()
def is_appengine_sandbox():
return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27"
def is_local_appengine():
return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
"SERVER_SOFTWARE", ""
... | --- +++ @@ -1,3 +1,6 @@+"""
+This module provides means to detect the App Engine environment.
+"""
import os
@@ -7,6 +10,12 @@
def is_appengine_sandbox():
+ """Reports if the app is running in the first generation sandbox.
+
+ The second generation runtimes are technically still in a sandbox, but it
+ ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py |
Add missing documentation to my Python functions | from __future__ import absolute_import
import OpenSSL.crypto
import OpenSSL.SSL
from cryptography import x509
from cryptography.hazmat.backends.openssl import backend as openssl_backend
try:
from cryptography.x509 import UnsupportedExtension
except ImportError:
# UnsupportedExtension is gone in cryptography >... | --- +++ @@ -1,3 +1,50 @@+"""
+TLS with SNI_-support for Python 2. Follow these instructions if you would
+like to verify TLS certificates in Python 2. Note, the default libraries do
+*not* do certificate checking; you need to do additional work to validate
+certificates yourself.
+
+This needs the following packages in... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py |
Document my Python code with docstrings | import math
from functools import lru_cache
from time import monotonic
from typing import Iterable, List, Optional
from .color import Color, blend_rgb
from .color_triplet import ColorTriplet
from .console import Console, ConsoleOptions, RenderResult
from .jupyter import JupyterMixin
from .measure import Measurement
fr... | --- +++ @@ -16,6 +16,19 @@
class ProgressBar(JupyterMixin):
+ """Renders a (progress) bar. Used by rich.progress.
+
+ Args:
+ total (float, optional): Number of steps in the bar. Defaults to 100. Set to None to render a pulsing animation.
+ completed (float, optional): Number of steps completed.... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/progress_bar.py |
Generate docstrings with examples | from __future__ import absolute_import
import platform
from ctypes import (
CDLL,
CFUNCTYPE,
POINTER,
c_bool,
c_byte,
c_char_p,
c_int32,
c_long,
c_size_t,
c_uint32,
c_ulong,
c_void_p,
)
from ctypes.util import find_library
from ...packages.six import raise_from
if plat... | --- +++ @@ -1,3 +1,34 @@+"""
+This module uses ctypes to bind a whole bunch of functions and constants from
+SecureTransport. The goal here is to provide the low-level API to
+SecureTransport. These are essentially the C-level functions and constants, and
+they're pretty gross to work with.
+
+This code is a bastardise... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py |
Add docstrings to clarify complex logic | # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
# Licensed to PSF under a Contributor Agreement.
from __future__ import annotations
from collections.abc import Iterable
import string
from types import MappingProxyType
from typing import Any, BinaryIO, NamedTuple
from ._re import (
R... | --- +++ @@ -51,9 +51,11 @@
class TOMLDecodeError(ValueError):
+ """An error raised if a document is not valid TOML."""
def load(__fp: BinaryIO, *, parse_float: ParseFloat = float) -> dict[str, Any]:
+ """Parse TOML from a binary file object."""
b = __fp.read()
try:
s = b.decode()
@@ -6... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/tomli/_parser.py |
Write docstrings for data processing functions | # -*- coding: utf-8 -*-
from __future__ import absolute_import
import itertools
import sys
from weakref import ref
__all__ = ["weakref_finalize"]
class weakref_finalize(object):
# Finalizer objects don't have any state of their own. They are
# just used as keys to lookup _Info objects in the registry. Th... | --- +++ @@ -1,4 +1,10 @@ # -*- coding: utf-8 -*-
+"""
+backports.weakref_finalize
+~~~~~~~~~~~~~~~~~~
+
+Backports the Python 3 ``weakref.finalize`` method.
+"""
from __future__ import absolute_import
import itertools
@@ -9,6 +15,16 @@
class weakref_finalize(object):
+ """Class for finalization of weakrefabl... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/weakref_finalize.py |
Add docstrings that explain purpose and usage |
from __future__ import absolute_import
import io
import logging
import warnings
from ..exceptions import (
HTTPError,
HTTPWarning,
MaxRetryError,
ProtocolError,
SSLError,
TimeoutError,
)
from ..packages.six.moves.urllib.parse import urljoin
from ..request import RequestMethods
from ..response... | --- +++ @@ -1,3 +1,42 @@+"""
+This module provides a pool manager that uses Google App Engine's
+`URLFetch Service <https://cloud.google.com/appengine/docs/python/urlfetch>`_.
+
+Example usage::
+
+ from pip._vendor.urllib3 import PoolManager
+ from pip._vendor.urllib3.contrib.appengine import AppEngineManager, i... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/appengine.py |
Add docstrings for better understanding | from dataclasses import dataclass, field, replace
from typing import (
TYPE_CHECKING,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Sequence,
Tuple,
Union,
)
from . import box, errors
from ._loop import loop_first_last, loop_last
from ._pick import pick_bool
from ._ratio import ratio_... | --- +++ @@ -37,6 +37,35 @@
@dataclass
class Column:
+ """Defines a column within a ~Table.
+
+ Args:
+ title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
+ caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
+ ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/table.py |
Add well-formatted docstrings | import inspect
from functools import partial
from typing import (
Any,
Callable,
Iterable,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
overload,
)
T = TypeVar("T")
Result = Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]
RichReprResult = Result
class... | --- +++ @@ -21,6 +21,7 @@
class ReprError(Exception):
+ """An error occurred when attempting to build a repr."""
@overload
@@ -36,9 +37,11 @@ def auto(
cls: Optional[Type[T]] = None, *, angular: Optional[bool] = None
) -> Union[Type[T], Callable[[Type[T]], Type[T]]]:
+ """Class decorator to create ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/repr.py |
Help me document legacy Python code | from __future__ import absolute_import
import email.utils
import mimetypes
import re
from .packages import six
def guess_content_type(filename, default="application/octet-stream"):
if filename:
return mimetypes.guess_type(filename)[0] or default
return default
def format_header_param_rfc2231(name,... | --- +++ @@ -8,12 +8,35 @@
def guess_content_type(filename, default="application/octet-stream"):
+ """
+ Guess the "Content-Type" of a file.
+
+ :param filename:
+ The filename to guess the "Content-Type" of using :mod:`mimetypes`.
+ :param default:
+ If no "Content-Type" can be guessed, de... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/fields.py |
Add concise docstrings to each method | import os
import platform
import socket
import ssl
import sys
import typing
import _ssl # type: ignore[import-not-found]
from ._ssl_constants import (
_original_SSLContext,
_original_super_SSLContext,
_truststore_SSLContext_dunder_class,
_truststore_SSLContext_super_class,
)
if platform.system() == ... | --- +++ @@ -30,6 +30,9 @@
def inject_into_ssl() -> None:
+ """Injects the :class:`truststore.SSLContext` into the ``ssl``
+ module by replacing :class:`ssl.SSLContext`.
+ """
setattr(ssl, "SSLContext", SSLContext)
# urllib3 holds on to its own reference of ssl.SSLContext
# so we need to repl... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/truststore/_api.py |
Document all public functions with docstrings | from __future__ import absolute_import
import datetime
import logging
import os
import re
import socket
import warnings
from socket import error as SocketError
from socket import timeout as SocketTimeout
from .packages import six
from .packages.six.moves.http_client import HTTPConnection as _HTTPConnection
from .pack... | --- +++ @@ -74,6 +74,30 @@
class HTTPConnection(_HTTPConnection, object):
+ """
+ Based on :class:`http.client.HTTPConnection` but provides an extra constructor
+ backwards-compatibility layer between older and newer Pythons.
+
+ Additional keyword parameters are used to configure attributes of the conn... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/connection.py |
Generate docstrings with parameter types | import abc
import collections
import collections.abc
import contextlib
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
__all__ = [
# Super-special typing primitives.
'Any',
'ClassVar',
'Concatenate',
'Final',
'LiteralString',
'... | --- +++ @@ -190,6 +190,14 @@ return super().__repr__()
class Any(metaclass=_AnyMeta):
+ """Special type indicating an unconstrained type.
+ - Any is compatible with every type.
+ - Any assumed to have all methods.
+ - All values assumed to be instances of Any.
+ Not... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/typing_extensions.py |
Create documentation for each function signature | # -*- coding: utf-8 -*-
import io
from socket import SocketIO
def backport_makefile(
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
):
if not set(mode) <= {"r", "w", "b"}:
raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,))
writing = "w" in mode
readi... | --- +++ @@ -1,4 +1,11 @@ # -*- coding: utf-8 -*-
+"""
+backports.makefile
+~~~~~~~~~~~~~~~~~~
+
+Backports the Python 3 ``socket.makefile`` method for use with anything that
+wants to create a "fake" socket object.
+"""
import io
from socket import SocketIO
@@ -6,6 +13,9 @@ def backport_makefile(
self, mode="r... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py |
Add docstrings for better understanding | from __future__ import absolute_import
import binascii
import codecs
import os
from io import BytesIO
from .fields import RequestField
from .packages import six
from .packages.six import b
writer = codecs.lookup("utf-8")[3]
def choose_boundary():
boundary = binascii.hexlify(os.urandom(16))
if not six.PY2:
... | --- +++ @@ -13,6 +13,9 @@
def choose_boundary():
+ """
+ Our embarrassingly-simple replacement for mimetools.choose_boundary.
+ """
boundary = binascii.hexlify(os.urandom(16))
if not six.PY2:
boundary = boundary.decode("ascii")
@@ -20,6 +23,13 @@
def iter_field_objects(fields):
+ ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/filepost.py |
Add standardized docstrings across the file | from __future__ import absolute_import
import warnings
from logging import getLogger
from ntlm import ntlm
from .. import HTTPSConnectionPool
from ..packages.six.moves.http_client import HTTPSConnection
warnings.warn(
"The 'urllib3.contrib.ntlmpool' module is deprecated and will be removed "
"in urllib3 v2.... | --- +++ @@ -1,3 +1,8 @@+"""
+NTLM authenticating pool, contributed by erikcederstran
+
+Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
+"""
from __future__ import absolute_import
import warnings
@@ -20,10 +25,18 @@
class NTLMConnectionPool(HTTPSConnectionPool):
+ """
+ Implements an ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py |
Generate consistent docstrings | import os.path
import platform
import re
import sys
import textwrap
from abc import ABC, abstractmethod
from pathlib import Path
from typing import (
Any,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Sequence,
Set,
Tuple,
Type,
Union,
)
from pip._vendor.pygments.lexer import ... | --- +++ @@ -121,17 +121,21 @@
class SyntaxTheme(ABC):
+ """Base class for a syntax theme."""
@abstractmethod
def get_style_for_token(self, token_type: TokenType) -> Style:
+ """Get a style for a given Pygments token."""
raise NotImplementedError # pragma: no cover
@abstractmet... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/syntax.py |
Document all public functions with docstrings | # -*- coding: utf-8 -*-
from __future__ import absolute_import
try:
import socks
except ImportError:
import warnings
from ..exceptions import DependencyWarning
warnings.warn(
(
"SOCKS support in urllib3 requires the installation of optional "
"dependencies: specificall... | --- +++ @@ -1,4 +1,43 @@ # -*- coding: utf-8 -*-
+"""
+This module contains provisional support for SOCKS proxies from within
+urllib3. This module supports SOCKS4, SOCKS4A (an extension of SOCKS4), and
+SOCKS5. To enable its functionality, either install PySocks or install this
+module with the ``socks`` extra.
+
+The... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py |
Generate consistent docstrings | from typing import Any, Generic, List, Optional, TextIO, TypeVar, Union, overload
from . import get_console
from .console import Console
from .text import Text, TextType
PromptType = TypeVar("PromptType")
DefaultType = TypeVar("DefaultType")
class PromptError(Exception):
class InvalidResponse(PromptError):
d... | --- +++ @@ -9,9 +9,16 @@
class PromptError(Exception):
+ """Exception base class for prompt related errors."""
class InvalidResponse(PromptError):
+ """Exception to indicate a response was invalid. Raise this within process_response() to indicate an error
+ and provide an error message.
+
+ Args:
+... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/prompt.py |
Document all public functions with docstrings | from __future__ import absolute_import
try:
from collections.abc import Mapping, MutableMapping
except ImportError:
from collections import Mapping, MutableMapping
try:
from threading import RLock
except ImportError: # Platform-specific: No threads available
class RLock:
def __enter__(self):
... | --- +++ @@ -29,6 +29,18 @@
class RecentlyUsedContainer(MutableMapping):
+ """
+ Provides a thread-safe dict-like container which maintains up to
+ ``maxsize`` keys while throwing away the least-recently-used keys beyond
+ ``maxsize``.
+
+ :param maxsize:
+ Maximum number of recent elements to ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/_collections.py |
Create docstrings for reusable components | import sys
from functools import lru_cache
from marshal import dumps, loads
from random import randint
from typing import Any, Dict, Iterable, List, Optional, Type, Union, cast
from . import errors
from .color import Color, ColorParseError, ColorSystem, blend_rgb
from .repr import Result, rich_repr
from .terminal_them... | --- +++ @@ -14,6 +14,7 @@
class _Bit:
+ """A descriptor to get/set a style attribute bit."""
__slots__ = ["bit"]
@@ -28,6 +29,31 @@
@rich_repr
class Style:
+ """A terminal style.
+
+ A terminal style consists of a color (`color`), a background color (`bgcolor`), and a number of attributes, such... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/style.py |
Add docstrings for internal functions | from __future__ import absolute_import
import contextlib
import ctypes
import errno
import os.path
import shutil
import socket
import ssl
import struct
import threading
import weakref
from .. import util
from ..packages import six
from ..util.ssl_ import PROTOCOL_TLS_CLIENT
from ._securetransport.bindings import Core... | --- +++ @@ -1,3 +1,56 @@+"""
+SecureTranport support for urllib3 via ctypes.
+
+This makes platform-native TLS available to urllib3 users on macOS without the
+use of a compiler. This is an important feature because the Python Package
+Index is moving to become a TLSv1.2-or-higher server, and the default OpenSSL
+that ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/contrib/securetransport.py |
Document this script properly | from enum import IntEnum
from functools import lru_cache
from itertools import filterfalse
from logging import getLogger
from operator import attrgetter
from typing import (
TYPE_CHECKING,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Sequence,
Tuple,
Type,
Union,
)
from .cells im... | --- +++ @@ -33,6 +33,7 @@
class ControlType(IntEnum):
+ """Non-printable control codes which typically translate to ANSI codes."""
BELL = 1
CARRIAGE_RETURN = 2
@@ -61,6 +62,17 @@
@rich_repr()
class Segment(NamedTuple):
+ """A piece of text with associated style. Segments are produced by the Con... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/segment.py |
Add docstrings for utility scripts | from __future__ import absolute_import
import errno
import logging
import re
import socket
import sys
import warnings
from socket import error as SocketError
from socket import timeout as SocketTimeout
from ._collections import HTTPHeaderDict
from .connection import (
BaseSSLError,
BrokenPipeError,
DummyC... | --- +++ @@ -67,6 +67,15 @@
# Pool objects
class ConnectionPool(object):
+ """
+ Base class for all connection pools, such as
+ :class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
+
+ .. note::
+ ConnectionPool.urlopen() does not normalize or percent-encode target URIs
+ which is u... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py |
Add missing documentation to my Python functions | from __future__ import absolute_import
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
# Base Exceptions
class HTTPError(Exception):
pass
class HTTPWarning(Warning):
pass
class PoolError(HTTPError):
def __init__(self, pool, message):
self.pool = pool
... | --- +++ @@ -6,16 +6,19 @@
class HTTPError(Exception):
+ """Base exception used by this module."""
pass
class HTTPWarning(Warning):
+ """Base warning used by this module."""
pass
class PoolError(HTTPError):
+ """Base exception for errors caused within a pool."""
def __init__(s... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/exceptions.py |
Document this script properly | from typing import Any, cast, Set, TYPE_CHECKING
from inspect import isclass
if TYPE_CHECKING:
from pip._vendor.rich.console import RenderableType
_GIBBERISH = """aihwerij235234ljsdnp34ksodfipwoe234234jlskjdf"""
def is_renderable(check_object: Any) -> bool:
return (
isinstance(check_object, str)
... | --- +++ @@ -8,6 +8,7 @@
def is_renderable(check_object: Any) -> bool:
+ """Check if an object may be rendered by Rich."""
return (
isinstance(check_object, str)
or hasattr(check_object, "__rich__")
@@ -16,6 +17,14 @@
def rich_cast(renderable: object) -> "RenderableType":
+ """Cast a... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/protocol.py |
Expand my code with proper documentation strings | from __future__ import absolute_import
# Set default logging handler to avoid "No handler found" warnings.
import logging
import warnings
from logging import NullHandler
from . import exceptions
from ._version import __version__
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
... | --- +++ @@ -1,3 +1,6 @@+"""
+Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more
+"""
from __future__ import absolute_import
# Set default logging handler to avoid "No handler found" warnings.
@@ -58,6 +61,12 @@
def add_stderr_logger(level=logging.DEBUG):
+ """... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/__init__.py |
Add docstrings with type hints explained | from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Optional, Tuple
from .highlighter import ReprHighlighter
from .panel import Panel
from .pretty import Pretty
from .table import Table
from .text import Text, TextType
if TYPE_CHECKING:
from .console import ConsoleRenderable
def render_sc... | --- +++ @@ -20,11 +20,26 @@ max_length: Optional[int] = None,
max_string: Optional[int] = None,
) -> "ConsoleRenderable":
+ """Render python variables in a given scope.
+
+ Args:
+ scope (Mapping): A mapping containing variable names and values.
+ title (str, optional): Optional title. Def... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/rich/scope.py |
Replace inline comments with docstrings | # Copyright (c) 2010-2020 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... | --- +++ @@ -18,6 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+"""Utilities for writing code that runs on Python 2 and 3"""
from __future__ import absolute_import
@@ -77,10 +78,12 @@
def _add_doc(func, doc):
+ """Add documentation to a function."""
... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/packages/six.py |
Add return value explanations in docstrings | from __future__ import absolute_import
import collections
import functools
import logging
from ._collections import HTTPHeaderDict, RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme
from .exceptions import (
LocationValueError,
MaxRetryError,
ProxySc... | --- +++ @@ -77,6 +77,25 @@
def _default_key_normalizer(key_class, request_context):
+ """
+ Create a pool key out of a request context dictionary.
+
+ According to RFC 3986, both the scheme and host are case-insensitive.
+ Therefore, this function normalizes both before constructing the pool
+ key fo... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/poolmanager.py |
Provide clean and structured docstrings | from __future__ import absolute_import
import sys
from .filepost import encode_multipart_formdata
from .packages import six
from .packages.six.moves.urllib.parse import urlencode
__all__ = ["RequestMethods"]
class RequestMethods(object):
_encode_url_methods = {"DELETE", "GET", "HEAD", "OPTIONS"}
def __in... | --- +++ @@ -10,6 +10,33 @@
class RequestMethods(object):
+ """
+ Convenience mixin for classes who implement a :meth:`urlopen` method, such
+ as :class:`urllib3.HTTPConnectionPool` and
+ :class:`urllib3.PoolManager`.
+
+ Provides behavior for making common types of HTTP request methods and
+ decid... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/request.py |
Create documentation for each function signature | from __future__ import absolute_import
import io
import logging
import sys
import warnings
import zlib
from contextlib import contextmanager
from socket import error as SocketError
from socket import timeout as SocketTimeout
brotli = None
from . import util
from ._collections import HTTPHeaderDict
from .connection i... | --- +++ @@ -121,6 +121,13 @@
class MultiDecoder(object):
+ """
+ From RFC7231:
+ If one or more encodings have been applied to a representation, the
+ sender that applied the encodings MUST generate a Content-Encoding
+ header field that lists the content codings in the order in which
+ ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/response.py |
Add docstrings to existing functions | from __future__ import absolute_import
from base64 import b64encode
from ..exceptions import UnrewindableBodyError
from ..packages.six import b, integer_types
# Pass as a value within ``headers`` to skip
# emitting some HTTP headers that are added automatically.
# The only headers that are supported are ``Accept-Enc... | --- +++ @@ -25,6 +25,40 @@ proxy_basic_auth=None,
disable_cache=None,
):
+ """
+ Shortcuts for generating request headers.
+
+ :param keep_alive:
+ If ``True``, adds 'connection: keep-alive' header.
+
+ :param accept_encoding:
+ Can be a boolean, list, or string.
+ ``True`` tr... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/request.py |
Add docstrings to my Python code | from __future__ import absolute_import
import email
import logging
import re
import time
import warnings
from collections import namedtuple
from itertools import takewhile
from ..exceptions import (
ConnectTimeoutError,
InvalidHeader,
MaxRetryError,
ProtocolError,
ProxyError,
ReadTimeoutError,... | --- +++ @@ -90,6 +90,141 @@
@six.add_metaclass(_RetryMeta)
class Retry(object):
+ """Retry configuration.
+
+ Each retry attempt will create a new Retry object with updated values, so
+ they can be safely reused.
+
+ Retries can be defined as a default for a pool::
+
+ retries = Retry(connect=5, r... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/retry.py |
Add docstrings to incomplete code | from __future__ import absolute_import
import hmac
import os
import sys
import warnings
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256
from ..exceptions import (
InsecurePlatformWarning,
ProxySchemeUnsupported,
SNIMissingWarning,
SSLError,
)
from ..packages import six
fr... | --- +++ @@ -28,6 +28,12 @@
def _const_compare_digest_backport(a, b):
+ """
+ Compare two digests of equal length in constant time.
+
+ The digests must be of type str/bytes.
+ Returns True if the digests match, and False otherwise.
+ """
result = abs(len(a) - len(b))
for left, right in zip(... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_.py |
Write proper docstrings for these functions | from __future__ import absolute_import
import socket
from ..contrib import _appengine_environ
from ..exceptions import LocationParseError
from ..packages import six
from .wait import NoWayToWaitForSocketError, wait_for_read
def is_connection_dropped(conn): # Platform-specific
sock = getattr(conn, "sock", False... | --- +++ @@ -9,6 +9,15 @@
def is_connection_dropped(conn): # Platform-specific
+ """
+ Returns True if the connection is dropped and should be closed.
+
+ :param conn:
+ :class:`http.client.HTTPConnection` object.
+
+ Note: For platforms like AppEngine, this will always return ``False`` to
+ l... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/connection.py |
Generate consistent docstrings | from __future__ import absolute_import
from email.errors import MultipartInvariantViolationDefect, StartBoundaryNotFoundDefect
from ..exceptions import HeaderParsingError
from ..packages.six.moves import http_client as httplib
def is_fp_closed(obj):
try:
# Check `isclosed()` first, in case Python3 does... | --- +++ @@ -7,6 +7,12 @@
def is_fp_closed(obj):
+ """
+ Checks whether a given file-like object is closed.
+
+ :param obj:
+ The file-like object to check.
+ """
try:
# Check `isclosed()` first, in case Python3 doesn't set `closed`.
@@ -32,6 +38,17 @@
def assert_header_parsing... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/response.py |
Add well-formatted docstrings | from .ssl_ import create_urllib3_context, resolve_cert_reqs, resolve_ssl_version
def connection_requires_http_tunnel(
proxy_url=None, proxy_config=None, destination_scheme=None
):
# If we're not using a proxy, no way to use a tunnel.
if proxy_url is None:
return False
# HTTP destinations neve... | --- +++ @@ -4,6 +4,16 @@ def connection_requires_http_tunnel(
proxy_url=None, proxy_config=None, destination_scheme=None
):
+ """
+ Returns True if the connection requires an HTTP CONNECT through the proxy.
+
+ :param URL proxy_url:
+ URL of the proxy.
+ :param ProxyConfig proxy_config:
+ ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/proxy.py |
Include argument descriptions in docstrings | from __future__ import absolute_import
import re
from collections import namedtuple
from ..exceptions import LocationParseError
from ..packages import six
url_attrs = ["scheme", "auth", "host", "port", "path", "query", "fragment"]
# We only want to normalize urls with an HTTP(S) scheme.
# urllib3 infers URLs withou... | --- +++ @@ -80,6 +80,11 @@
class Url(namedtuple("Url", url_attrs)):
+ """
+ Data structure for representing an HTTP URL. Used as a return value for
+ :func:`parse_url`. Both the scheme and host are normalized as they are
+ both case-insensitive according to RFC 3986.
+ """
__slots__ = ()
@@ ... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/url.py |
Add docstrings to improve code quality | from __future__ import absolute_import
import time
# The default socket timeout, used by httplib to indicate that no timeout was; specified by the user
from socket import _GLOBAL_DEFAULT_TIMEOUT, getdefaulttimeout
from ..exceptions import TimeoutStateError
# A sentinel value to indicate that no timeout was specifie... | --- +++ @@ -17,6 +17,83 @@
class Timeout(object):
+ """Timeout configuration.
+
+ Timeouts can be defined as a default for a pool:
+
+ .. code-block:: python
+
+ timeout = Timeout(connect=2.0, read=7.0)
+ http = PoolManager(timeout=timeout)
+ response = http.request('GET', 'http://example... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/timeout.py |
Create simple docstrings for beginners | import io
import socket
import ssl
from ..exceptions import ProxySchemeUnsupported
from ..packages import six
SSL_BLOCKSIZE = 16384
class SSLTransport:
@staticmethod
def _validate_ssl_context_for_tls_in_tls(ssl_context):
if not hasattr(ssl_context, "wrap_bio"):
if six.PY2:
... | --- +++ @@ -9,9 +9,25 @@
class SSLTransport:
+ """
+ The SSLTransport wraps an existing socket and establishes an SSL connection.
+
+ Contrary to Python's implementation of SSLSocket, it allows you to chain
+ multiple TLS connections together. It's particularly useful if you need to
+ implement TLS w... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/ssltransport.py |
Insert docstrings into my code | import errno
import select
import sys
from functools import partial
try:
from time import monotonic
except ImportError:
from time import time as monotonic
__all__ = ["NoWayToWaitForSocketError", "wait_for_read", "wait_for_write"]
class NoWayToWaitForSocketError(Exception):
pass
# How should we wait on... | --- +++ @@ -139,8 +139,14 @@
def wait_for_read(sock, timeout=None):
+ """Waits for reading to be available on a given socket.
+ Returns True if the socket is readable, or False if the timeout expired.
+ """
return wait_for_socket(sock, read=True, timeout=timeout)
def wait_for_write(sock, timeout=... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/wait.py |
Add professional docstrings to my codebase |
# Note: This file is under the PSF license as the code comes from the python
# stdlib. http://docs.python.org/3/license.html
import re
import sys
# ipaddress has been backported to 2.6+ in pypi. If it is installed on the
# system, use it to handle IPAddress ServerAltnames (this was added in
# python-3.5) otherwis... | --- +++ @@ -1,3 +1,4 @@+"""The match_hostname() function from Python 3.3.3, essential when using SSL."""
# Note: This file is under the PSF license as the code comes from the python
# stdlib. http://docs.python.org/3/license.html
@@ -22,6 +23,10 @@
def _dnsname_match(dn, hostname, max_wildcards=1):
+ """Ma... | https://raw.githubusercontent.com/geekcomputers/Python/HEAD/venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py |
Help me comply with documentation standards | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Benchmark configuration settings and constants.
+
+Centralized configuration for tokenization tests, model parameters,
+display formatting, and test text sources.
+"""
from datacla... | https://raw.githubusercontent.com/google/langextract/HEAD/benchmarks/config.py |
Document classes and their methods | #!/usr/bin/env python3
# Copyright 2025 Google LLC.
#
# 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... | --- +++ @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Publish a new version to Zenodo via REST API.
+
+This script reads project metadata from pyproject.toml to avoid duplication.
+For subsequent releases, it creates new versions from th... | https://raw.githubusercontent.com/google/langextract/HEAD/.github/scripts/zenodo_publish.py |
Document functions with detailed explanations | #!/usr/bin/env python3
# Copyright 2025 Google LLC.
#
# 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... | --- +++ @@ -13,6 +13,28 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""LangExtract benchmark suite for performance and quality testing.
+
+Measures tokenization speed and extraction quality across multiple languages
+and text types. Automatically downloa... | https://raw.githubusercontent.com/google/langextract/HEAD/benchmarks/benchmark.py |
Fully document this Python code with docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Helper functions for benchmark text retrieval and analysis."""
import subprocess
from typing import Any
@@ -23,6 +24,14 @@
def download_text(url: str) -> str:
+ """Download te... | https://raw.githubusercontent.com/google/langextract/HEAD/benchmarks/utils.py |
Write docstrings for backend logic | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Base interfaces for language models."""
from __future__ import annotations
import abc
@@ -28,8 +29,20 @@
class BaseLanguageModel(abc.ABC):
+ """An abstract inference class for... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/base_model.py |
Add docstrings to improve readability | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""LangExtract: Extract structured information from text with LLMs.
+
+This package provides the main extract and visualize functions,
+with lazy loading for other submodules accessed vi... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/__init__.py |
Add docstrings to make code maintainable | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Visualization generation for benchmark results.
+
+Creates multi-panel plots showing tokenization performance, extraction metrics,
+and cross-language comparisons.
+"""
from dateti... | https://raw.githubusercontent.com/google/langextract/HEAD/benchmarks/plotting.py |
Add docstrings following best practices | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Library for breaking documents into chunks of sentences.
+
+When a text-to-text model (e.g. a large language model with a fixed context
+size) can not accommodate a large document, th... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/chunking.py |
Annotate my code with docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Classes used to represent core data types of annotation pipeline."""
from __future__ import annotations
import dataclasses
@@ -48,6 +49,12 @@
@dataclasses.dataclass
class CharIn... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/data.py |
Add concise docstrings to each method | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Debug utilities for LangExtract."""
from __future__ import annotations
import functools
@@ -46,6 +47,7 @@
def _safe_repr(obj: Any) -> str:
+ """Truncate object repr for safe l... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/debug_utils.py |
Write beginner-friendly docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Prompt validation for alignment checks on few-shot examples."""
from __future__ import annotations
@@ -41,6 +42,7 @@
class PromptValidationLevel(enum.Enum):
+ """Validation l... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/prompt_validation.py |
Write docstrings describing each step | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Library for data conversion between AnnotatedDocument and JSON."""
from __future__ import annotations
import dataclasses
@@ -24,6 +25,19 @@
def enum_asdict_factory(items: Itera... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/data_lib.py |
Generate documentation strings for clarity | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tokenization utilities for text.
+
+Provides methods to split text into regex-based or Unicode-aware tokens.
+Tokenization is used for alignment in `resolver.py` and for determining
+... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/tokenizer.py |
Add clean documentation to messy code | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Built-in provider registration configuration.
+
+This module defines the registration details for all built-in providers,
+using patterns from the centralized patterns module.
+"""
... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/providers/builtin_registry.py |
Generate consistent documentation across files | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Gemini provider for LangExtract."""
# pylint: disable=duplicate-code
from __future__ import annotations
@@ -53,6 +54,7 @@ )
@dataclasses.dataclass(init=False)
class GeminiLanguag... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/providers/gemini.py |
Create docstrings for each class method | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Provider package for LangExtract.
+
+This package contains provider implementations for various LLM backends.
+Each provider can be imported independently for fine-grained dependency
... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/providers/__init__.py |
Add docstrings with type hints explained | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Supports Input and Output Operations for Data Annotations."""
from __future__ import annotations
import abc
@@ -35,16 +36,31 @@
class InvalidDatasetError(exceptions.LangExtract... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/io.py |
Add docstrings to make code maintainable | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Language model inference compatibility layer.
+
+This module provides backward compatibility for the inference module.
+New code should import from langextract.core.base_model instead... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/inference.py |
Document classes and their methods | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Core data types for LangExtract."""
from __future__ import annotations
import dataclasses
@@ -27,24 +28,32 @@
class FormatType(enum.Enum):
+ """Enumeration of prompt output fo... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/types.py |
Write beginner-friendly docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Main extraction API for LangExtract."""
from __future__ import annotations
@@ -62,6 +63,115 @@ show_progress: bool = True,
tokenizer: tokenizer_lib.Tokenizer | None = Non... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/extraction.py |
Help me add docstrings to my project | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Core schema abstractions for LangExtract."""
from __future__ import annotations
import abc
@@ -35,6 +36,7 @@
class BaseSchema(abc.ABC):
+ """Abstract base class for generating... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/schema.py |
Fill in missing docstrings in my code | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Compatibility shim for langextract.registry imports."""
# pylint: disable=duplicate-code
from __future__ import annotations
@@ -22,10 +23,11 @@
def __getattr__(name: str):
+ "... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/_compat/registry.py |
Fully document this Python code with docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Progress and visualization utilities for LangExtract."""
from __future__ import annotations
from typing import Any
@@ -33,6 +34,17 @@ def create_download_progress_bar(
total_s... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/progress.py |
Generate consistent docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Provider discovery and registration system.
+
+This module provides centralized provider discovery without circular imports.
+It supports both built-in providers and third-party provi... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/plugins.py |
Create docstrings for all classes and functions | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Core error types for LangExtract.
+
+This module defines all base exceptions for LangExtract. These are the
+foundational error types that are used throughout the codebase.
+"""
fr... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/core/exceptions.py |
Write docstrings that follow conventions | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Factory for creating language model instances.
+
+This module provides a factory pattern for instantiating language models
+based on configuration, with support for environment variab... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/factory.py |
Create Google-style docstrings for my code | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Library for building prompts."""
from __future__ import annotations
import dataclasses
@@ -28,13 +29,21 @@
class PromptBuilderError(exceptions.LangExtractError):
+ """Failure ... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/prompting.py |
Fill in missing docstrings in my code | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Compatibility shim for langextract.inference imports."""
from __future__ import annotations
@@ -20,6 +21,7 @@
class InferenceType(enum.Enum):
+ """Enum for inference types - ... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/_compat/inference.py |
Generate NumPy-style docstrings | import numpy as np
import random
import torch
from basicsr.data.degradations import random_add_gaussian_noise_pt, random_add_poisson_noise_pt
from basicsr.data.transforms import paired_random_crop
from basicsr.models.sr_model import SRModel
from basicsr.utils import DiffJPEG, USMSharp
from basicsr.utils.img_process_uti... | --- +++ @@ -12,6 +12,13 @@
@MODEL_REGISTRY.register()
class RealESRNetModel(SRModel):
+ """RealESRNet Model for Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data.
+
+ It is trained without GAN losses.
+ It mainly performs:
+ 1. randomly synthesize LQ images in GPU tensors
+... | https://raw.githubusercontent.com/xinntao/Real-ESRGAN/HEAD/realesrgan/models/realesrnet_model.py |
Improve documentation using docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -13,6 +13,7 @@ # limitations under the License.
#!/usr/bin/env python3
+"""Validation for COMMUNITY_PROVIDERS.md plugin registry table."""
import os
from pathlib import Path
@@ -45,6 +46,7 @@
def normalize_pypi(name: str) -> str:
+ """PEP 503 normalization for PyPI package names."""
return reg... | https://raw.githubusercontent.com/google/langextract/HEAD/scripts/validate_community_providers.py |
Add docstrings including usage examples | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,14 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utility functions for visualizing LangExtract extractions in notebooks.
+
+Example
+-------
+>>> import langextract as lx
+>>> doc = lx.extract(...)
+>>> lx.visualize(doc)
+"""
fro... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/visualization.py |
Document this module using docstrings | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Library for resolving LLM output.
+
+In the context of this module, a "resolver" is a component designed to parse and
+transform the textual output of an LLM into structured data.
+""... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/resolver.py |
Add structured docstrings to improve clarity | # Copyright 2025 Google LLC.
#
# 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, ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Gemini provider schema implementation."""
# pylint: disable=duplicate-code
from __future__ import annotations
@@ -28,18 +29,30 @@
@dataclasses.dataclass
class GeminiSchema(schem... | https://raw.githubusercontent.com/google/langextract/HEAD/langextract/providers/schemas/gemini.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.