repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/_phi.py | unsloth/registry/_phi.py | from unsloth.registry.registry import ModelInfo, ModelMeta, QuantType, _register_models
_IS_PHI_4_REGISTERED = False
_IS_PHI_4_INSTRUCT_REGISTERED = False
class PhiModelInfo(ModelInfo):
@classmethod
def construct_model_name(cls, base_name, version, size, quant_type, instruct_tag):
key = f"{base_name}... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/registry.py | unsloth/registry/registry.py | import warnings
from dataclasses import dataclass, field
from enum import Enum
class QuantType(Enum):
BNB = "bnb"
UNSLOTH = "unsloth" # dynamic 4-bit quantization
GGUF = "GGUF"
NONE = "none"
BF16 = "bf16" # only for Deepseek V3
# Tags for Hugging Face model paths
BNB_QUANTIZED_TAG = "bnb-4bit"... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/_mistral.py | unsloth/registry/_mistral.py | import copy
from unsloth.registry.registry import ModelInfo, ModelMeta, QuantType, _register_models
_IS_MISTRAL_SMALL_REGISTERED = False
_MISTRAL_SMALL_03_25_VERSION = "2503"
_MISTRAL_SMALL_01_25_VERSION = "2501"
_MISTRAL_SMALL_09_24_VERSION = "2409" # Not uploaded to unsloth
class MistralSmallModelInfo(ModelInfo... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/_llama.py | unsloth/registry/_llama.py | from unsloth.registry.registry import ModelInfo, ModelMeta, QuantType, _register_models
_IS_LLAMA_3_1_REGISTERED = False
_IS_LLAMA_3_2_REGISTERED = False
_IS_LLAMA_3_2_VISION_REGISTERED = False
class LlamaModelInfo(ModelInfo):
@classmethod
def construct_model_name(cls, base_name, version, size, quant_type, i... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/_gemma.py | unsloth/registry/_gemma.py | from unsloth.registry.registry import ModelInfo, ModelMeta, QuantType, _register_models
_IS_GEMMA_3_BASE_REGISTERED = False
_IS_GEMMA_3_INSTRUCT_REGISTERED = False
class GemmaModelInfo(ModelInfo):
@classmethod
def construct_model_name(cls, base_name, version, size, quant_type, instruct_tag):
key = f"... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/_deepseek.py | unsloth/registry/_deepseek.py | from unsloth.registry.registry import ModelInfo, ModelMeta, QuantType, _register_models
_IS_DEEPSEEK_V3_REGISTERED = False
_IS_DEEPSEEK_V3_0324_REGISTERED = False
_IS_DEEPSEEK_R1_REGISTERED = False
_IS_DEEPSEEK_R1_ZERO_REGISTERED = False
_IS_DEEPSEEK_R1_DISTILL_LLAMA_REGISTERED = False
_IS_DEEPSEEK_R1_DISTILL_QWEN_REG... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/registry/__init__.py | unsloth/registry/__init__.py | from ._deepseek import register_deepseek_models as _register_deepseek_models
from ._gemma import register_gemma_models as _register_gemma_models
from ._llama import register_llama_models as _register_llama_models
from ._mistral import register_mistral_models as _register_mistral_models
from ._phi import register_phi_mo... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/dataprep/synthetic.py | unsloth/dataprep/synthetic.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/dataprep/synthetic_configs.py | unsloth/dataprep/synthetic_configs.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/dataprep/__init__.py | unsloth/dataprep/__init__.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/layernorm.py | unsloth/kernels/layernorm.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
# Copyright 2024-present Andrej Karpathy & the llm.c team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/cross_entropy_loss.py | unsloth/kernels/cross_entropy_loss.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/swiglu.py | unsloth/kernels/swiglu.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/rms_layernorm.py | unsloth/kernels/rms_layernorm.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/rope_embedding.py | unsloth/kernels/rope_embedding.py | # Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
#... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/fast_lora.py | unsloth/kernels/fast_lora.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/flex_attention.py | unsloth/kernels/flex_attention.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/utils.py | unsloth/kernels/utils.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | true |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/geglu.py | unsloth/kernels/geglu.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/fp8.py | unsloth/kernels/fp8.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/__init__.py | unsloth/kernels/__init__.py | # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/__init__.py | unsloth/kernels/moe/__init__.py | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false | |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/benchmark/benchmark_fused_moe.py | unsloth/kernels/moe/benchmark/benchmark_fused_moe.py | import argparse
import time
from contextlib import nullcontext
import torch
from transformers import AutoConfig
from transformers.models.llama4 import Llama4TextConfig
from transformers.models.llama4.modeling_llama4 import Llama4TextMoe
from transformers.models.qwen3_moe import Qwen3MoeConfig
from transformers.models.... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/benchmark/utils.py | unsloth/kernels/moe/benchmark/utils.py | import argparse
import datetime
import json
import logging
import math
import os
from itertools import product
import pandas as pd
import torch
from grouped_gemm.kernels.tuning import (
KernelConfigBackward_dW,
KernelConfigBackward_dX,
KernelConfigForward,
KernelResult,
)
SEED = 42
def create_merge... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/tests/test_grouped_gemm.py | unsloth/kernels/moe/tests/test_grouped_gemm.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
from dataclasses import asdict
import pytest
import torch
from grouped_gemm.interface import (
grouped_gemm,
grouped_gemm_dW,
grouped_gemm_dX,
grouped_gemm_forward,
)
from... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | true |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/tests/moe_utils.py | unsloth/kernels/moe/tests/moe_utils.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
from dataclasses import dataclass, fields
import torch
import torch.nn as nn
from huggingface_hub import HfApi
from huggingface_hub.utils import _safetensors
from transformers.models.qwen3... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/tests/common.py | unsloth/kernels/moe/tests/common.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import itertools
from contextlib import contextmanager
from dataclasses import dataclass, field
import torch
from grouped_gemm.kernels.tuning import (
KernelConfig,
KernelConfigBa... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/tests/test_llama4_moe.py | unsloth/kernels/moe/tests/test_llama4_moe.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import argparse
import sys
from contextlib import contextmanager
from functools import partial
import pytest
import torch
from transformers import AutoConfig
from transformers.models.llama... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/tests/test_qwen3_moe.py | unsloth/kernels/moe/tests/test_qwen3_moe.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import argparse
from contextlib import contextmanager
import pytest
import torch
from transformers import AutoConfig
from transformers.models.qwen3_moe import Qwen3MoeConfig
from transform... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/tests/__init__.py | unsloth/kernels/moe/tests/__init__.py | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false | |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/interface.py | unsloth/kernels/moe/grouped_gemm/interface.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import logging
import warnings
from dataclasses import asdict
import torch
import triton
from grouped_gemm.kernels.backward import (
_autotuned_grouped_gemm_dW_kernel,
_autotuned_... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | true |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/__init__.py | unsloth/kernels/moe/grouped_gemm/__init__.py | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false | |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/reference/moe_ops.py | unsloth/kernels/moe/grouped_gemm/reference/moe_ops.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import torch
import torch.nn.functional as F
def permute(X: torch.Tensor, gather_indices: torch.Tensor, topk: int):
"""
Scatters X to a new tensor with shape [total_tokens, hidden... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/reference/moe_block.py | unsloth/kernels/moe/grouped_gemm/reference/moe_block.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import torch
from transformers.models.qwen3_moe.configuration_qwen3_moe import Qwen3MoeConfig
from transformers.models.qwen3_moe.modeling_qwen3_moe import Qwen3MoeSparseMoeBlock
from group... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/reference/__init__.py | unsloth/kernels/moe/grouped_gemm/reference/__init__.py | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false | |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/reference/layers/qwen3_moe.py | unsloth/kernels/moe/grouped_gemm/reference/layers/qwen3_moe.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
from dataclasses import dataclass
from typing import Tuple
import torch
import torch.nn.functional as F
from transformers.models.qwen3_moe.configuration_qwen3_moe import Qwen3MoeConfig
fro... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/reference/layers/llama4_moe.py | unsloth/kernels/moe/grouped_gemm/reference/layers/llama4_moe.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
from dataclasses import dataclass
from typing import Tuple
import torch
import torch.nn.functional as F
from transformers.models.llama4 import Llama4TextConfig
from transformers.models.lla... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/kernels/tuning.py | unsloth/kernels/moe/grouped_gemm/kernels/tuning.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
"""
Manual tuning utils
"""
from collections import OrderedDict
from dataclasses import asdict, dataclass, fields
from itertools import product
from typing import Optional
import pandas a... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/kernels/backward.py | unsloth/kernels/moe/grouped_gemm/kernels/backward.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import torch
import triton
import triton.language as tl
from grouped_gemm.kernels.autotuning import (
get_dW_kernel_configs,
get_dX_kernel_configs,
prune_dX_configs,
prune_... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/kernels/forward.py | unsloth/kernels/moe/grouped_gemm/kernels/forward.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
import torch
import triton
import triton.language as tl
from grouped_gemm.kernels.autotuning import (
get_forward_configs,
prune_kernel_configs_fwd,
)
#
# PERMUTE_X -> permute to... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/kernels/__init__.py | unsloth/kernels/moe/grouped_gemm/kernels/__init__.py | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false | |
unslothai/unsloth | https://github.com/unslothai/unsloth/blob/85bfdaf7ab3c32f95f98f3e3927164797fcc6d46/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py | unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py | # SPDX-License-Identifier: GNU Affero General Public License v3.0
# Copyright 2023-present the Unsloth team. All rights reserved.
"""
Autotuning utils
"""
import logging
from itertools import product
from typing import List
import torch
import triton
logger = logging.getLogger(__name__)
DEFAULT_M_BLOCK_SIZES = [64... | python | Apache-2.0 | 85bfdaf7ab3c32f95f98f3e3927164797fcc6d46 | 2026-01-04T14:39:29.397284Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/setup.py | setup.py | #!/usr/bin/env python
# This is a shim to hopefully allow Github to detect the package, build is done with poetry
import setuptools
if __name__ == "__main__":
setuptools.setup(name="rich")
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/benchmarks/benchmarks.py | benchmarks/benchmarks.py | from io import StringIO
from benchmarks import snippets
from rich.color import Color, ColorSystem
from rich.console import Console
from rich.pretty import Pretty
from rich.segment import Segment
from rich.style import Style
from rich.syntax import Syntax
from rich.table import Table
from rich.text import Text
class ... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/benchmarks/__init__.py | benchmarks/__init__.py | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false | |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/benchmarks/snippets.py | benchmarks/snippets.py | PYTHON_SNIPPET = '''
def layout_resolve(total: int, edges: Sequence[EdgeProtocol]) -> List[int]:
"""Divide total space to satisfy size, fraction, and min_size, constraints.
The returned list of integers should add up to total in most cases, unless it is
impossible to satisfy all the constraints. For instan... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tools/profile_divide.py | tools/profile_divide.py | from rich.segment import Segment
text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in vo... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tools/profile_pretty.py | tools/profile_pretty.py | import json
import io
from time import time
from rich.console import Console
from rich.pretty import Pretty
console = Console(file=io.StringIO(), color_system="truecolor", width=100)
with open("cats.json") as fh:
cats = json.load(fh)
console.begin_capture()
start = time()
pretty = Pretty(cats)
console.print(pr... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tools/make_emoji.py | tools/make_emoji.py | try:
import emoji
except ImportError:
print("pip install emoji")
raise
from emoji.unicode_codes import EMOJI_ALIAS_UNICODE
emoji = {k.lower().strip(":"): v for k, v in EMOJI_ALIAS_UNICODE.items()}
with open("_emoji_codes.py", "wt") as f:
f.write("EMOJI=" + str(emoji))
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tools/make_terminal_widths.py | tools/make_terminal_widths.py | import subprocess
from typing import List, Tuple
import sys
from rich.progress import Progress
from wcwidth import wcwidth
progress = Progress()
def make_widths_table() -> List[Tuple[int, int, int]]:
table: List[Tuple[int, int, int]] = []
append = table.append
make_table_task = progress.add_task("Cal... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tools/stress_test_pretty.py | tools/stress_test_pretty.py | from rich.console import Console
from rich.panel import Panel
from rich.pretty import Pretty
from rich._timer import timer
DATA = {
"foo": [1, 2, 3, (), {}, (1, 2, 3), {4, 5, 6, (7, 8, 9)}, "Hello, World"],
"bar": [None, (False, True)] * 2,
"Dune": {
"names": {
"Paul Atreides",
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/columns.py | rich/columns.py | from collections import defaultdict
from itertools import chain
from operator import itemgetter
from typing import Dict, Iterable, List, Optional, Tuple
from .align import Align, AlignMethod
from .console import Console, ConsoleOptions, RenderableType, RenderResult
from .constrain import Constrain
from .measure import... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/default_styles.py | rich/default_styles.py | from typing import Dict
from .style import Style
DEFAULT_STYLES: Dict[str, Style] = {
"none": Style.null(),
"reset": Style(
color="default",
bgcolor="default",
dim=False,
bold=False,
italic=False,
underline=False,
blink=False,
blink2=False,
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/spinner.py | rich/spinner.py | from typing import TYPE_CHECKING, List, Optional, Union, cast
from ._spinners import SPINNERS
from .measure import Measurement
from .table import Table
from .text import Text
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, RenderableType, RenderResult
from .style import StyleType
class Spinn... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_inspect.py | rich/_inspect.py | import inspect
from inspect import cleandoc, getdoc, getfile, isclass, ismodule, signature
from typing import Any, Collection, Iterable, Optional, Tuple, Type, Union
from .console import Group, RenderableType
from .control import escape_control_codes
from .highlighter import ReprHighlighter
from .jupyter import Jupyte... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/box.py | rich/box.py | from typing import TYPE_CHECKING, Iterable, List, Literal
from ._loop import loop_last
if TYPE_CHECKING:
from rich.console import ConsoleOptions
class Box:
"""Defines characters to render boxes.
┌─┬┐ top
│ ││ head
├─┼┤ head_row
│ ││ mid
├─┼┤ row
├─┼┤ foot_row
│ ││ foot
└─┴┘... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/table.py | rich/table.py | 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_... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | true |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_spinners.py | rich/_spinners.py | """
Spinners are from:
* cli-spinners:
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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 withou... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/panel.py | rich/panel.py | 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... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/markup.py | rich/markup.py | import re
from ast import literal_eval
from operator import attrgetter
from typing import Callable, Iterable, List, Match, NamedTuple, Optional, Tuple, Union
from ._emoji_replace import _emoji_replace
from .emoji import EmojiVariant
from .errors import MarkupError
from .style import Style
from .text import Span, Text
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/align.py | rich/align.py | from itertools import chain
from typing import TYPE_CHECKING, Iterable, Optional, Literal
from .constrain import Constrain
from .jupyter import JupyterMixin
from .measure import Measurement
from .segment import Segment
from .style import StyleType
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, Re... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_wrap.py | rich/_wrap.py | from __future__ import annotations
import re
from typing import Iterable
from ._loop import loop_last
from .cells import cell_len, chop_cells
re_word = re.compile(r"\s*\S+\s*")
def words(text: str) -> Iterable[tuple[int, int, str]]:
"""Yields each word from the text as a tuple
containing (start_index, end_... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_fileno.py | rich/_fileno.py | from __future__ import annotations
from typing import IO, Callable
def get_fileno(file_like: IO[str]) -> int | None:
"""Get fileno() from a file, accounting for poorly implemented file-like objects.
Args:
file_like (IO): A file-like object.
Returns:
int | None: The result of fileno if a... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/segment.py | rich/segment.py | 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... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/tree.py | rich/tree.py | 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... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_export_format.py | rich/_export_format.py | CONSOLE_HTML_FORMAT = """\
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
{stylesheet}
body {{
color: {foreground};
background-color: {background};
}}
</style>
</head>
<body>
<pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{c... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/themes.py | rich/themes.py | from .default_styles import DEFAULT_STYLES
from .theme import Theme
DEFAULT = Theme(DEFAULT_STYLES)
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/markdown.py | rich/markdown.py | from __future__ import annotations
import sys
from typing import ClassVar, Iterable, get_args
from markdown_it import MarkdownIt
from markdown_it.token import Token
from rich.table import Table
from . import box
from ._loop import loop_first
from ._stack import Stack
from .console import Console, ConsoleOptions, Ju... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_windows.py | rich/_windows.py | import sys
from dataclasses import dataclass
@dataclass
class WindowsConsoleFeatures:
"""Windows features available."""
vt: bool = False
"""The console supports VT codes."""
truecolor: bool = False
"""The console supports truecolor."""
try:
import ctypes
from ctypes import LibraryLoader... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_ratio.py | rich/_ratio.py | from fractions import Fraction
from math import ceil
from typing import cast, List, Optional, Sequence, Protocol
class Edge(Protocol):
"""Any object that defines an edge (such as Layout)."""
size: Optional[int] = None
ratio: int = 1
minimum_size: int = 1
def ratio_resolve(total: int, edges: Sequenc... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/bar.py | rich/bar.py | from typing import Optional, Union
from .color import Color
from .console import Console, ConsoleOptions, RenderResult
from .jupyter import JupyterMixin
from .measure import Measurement
from .segment import Segment
from .style import Style
# There are left-aligned characters for 1/8 to 7/8, but
# the right-aligned ch... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/live.py | rich/live.py | from __future__ import annotations
import sys
from threading import Event, RLock, Thread
from types import TracebackType
from typing import IO, TYPE_CHECKING, Any, Callable, List, Optional, TextIO, Type, cast
from . import get_console
from .console import Console, ConsoleRenderable, Group, RenderableType, RenderHook
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/control.py | rich/control.py | import time
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Union, Final
from .segment import ControlCode, ControlType, Segment
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, RenderResult
STRIP_CONTROL_CODES: Final = [
7, # Bell
8, # Backspace
11, # Vertical tab
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_windows_renderer.py | rich/_windows_renderer.py | from typing import Iterable, Sequence, Tuple, cast
from rich._win32_console import LegacyWindowsTerm, WindowsCoordinates
from rich.segment import ControlCode, ControlType, Segment
def legacy_windows_render(buffer: Iterable[Segment], term: LegacyWindowsTerm) -> None:
"""Makes appropriate Windows Console API calls... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/file_proxy.py | rich/file_proxy.py | import io
from typing import IO, TYPE_CHECKING, Any, List
from .ansi import AnsiDecoder
from .text import Text
if TYPE_CHECKING:
from .console import Console
class FileProxy(io.TextIOBase):
"""Wraps a file (e.g. sys.stdout) and redirects writes to a console."""
def __init__(self, console: "Console", fi... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/color_triplet.py | rich/color_triplet.py | from typing import NamedTuple, Tuple
class ColorTriplet(NamedTuple):
"""The red, green, and blue components of a color."""
red: int
"""Red component in 0 to 255 range."""
green: int
"""Green component in 0 to 255 range."""
blue: int
"""Blue component in 0 to 255 range."""
@property
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/measure.py | rich/measure.py | from operator import itemgetter
from typing import TYPE_CHECKING, Callable, NamedTuple, Optional, Sequence
from . import errors
from .protocol import is_renderable, rich_cast
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, RenderableType
class Measurement(NamedTuple):
"""Stores the minimum a... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_win32_console.py | rich/_win32_console.py | """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
windll: Any = None
if sys.platform == "win32":
wind... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/pager.py | rich/pager.py | from abc import ABC, abstractmethod
from typing import Any
class Pager(ABC):
"""Base class for a pager."""
@abstractmethod
def show(self, content: str) -> None:
"""Show content in pager.
Args:
content (str): Content to be displayed.
"""
class SystemPager(Pager):
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/console.py | rich/console.py | import inspect
import os
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 islice
from math i... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | true |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/styled.py | rich/styled.py | from typing import TYPE_CHECKING
from .measure import Measurement
from .segment import Segment
from .style import StyleType
if TYPE_CHECKING:
from .console import Console, ConsoleOptions, RenderResult, RenderableType
class Styled:
"""Apply a style to a renderable.
Args:
renderable (RenderableTy... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/cells.py | rich/cells.py | from __future__ import annotations
from functools import lru_cache
from typing import Callable
from ._cell_widths import CELL_WIDTHS
# Ranges of unicode ordinals that produce a 1-cell wide character
# This is non-exhaustive, but covers most common Western characters
_SINGLE_CELL_UNICODE_RANGES: list[tuple[int, int]]... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_emoji_replace.py | rich/_emoji_replace.py | from typing import Callable, Match, Optional
import re
from ._emoji_codes import EMOJI
_ReStringMatch = Match[str] # regex match object
_ReSubCallable = Callable[[_ReStringMatch], str] # Callable invoked by re.sub
_EmojiSubMethod = Callable[[_ReSubCallable, str], str] # Sub method of a compiled re
def _emoji_re... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_null_file.py | rich/_null_file.py | from types import TracebackType
from typing import IO, Iterable, Iterator, List, Optional, Type
class NullFile(IO[str]):
def close(self) -> None:
pass
def isatty(self) -> bool:
return False
def read(self, __n: int = 1) -> str:
return ""
def readable(self) -> bool:
re... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/palette.py | rich/palette.py | from math import sqrt
from functools import lru_cache
from typing import Sequence, Tuple, TYPE_CHECKING
from .color_triplet import ColorTriplet
if TYPE_CHECKING:
from rich.table import Table
class Palette:
"""A palette of available colors."""
def __init__(self, colors: Sequence[Tuple[int, int, int]]):
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_loop.py | rich/_loop.py | from typing import Iterable, Tuple, TypeVar
T = TypeVar("T")
def loop_first(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
"""Iterate and generate a tuple with a flag for first value."""
iter_values = iter(values)
try:
value = next(iter_values)
except StopIteration:
return
yiel... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/filesize.py | rich/filesize.py | """Functions for reporting filesizes. Borrowed from https://github.com/PyFilesystem/pyfilesystem2
The functions declared in this module should cover the different
use cases needed to generate a string representation of a file size
using several different units. Since there are many standards regarding
file size units,... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/__main__.py | rich/__main__.py | import colorsys
import io
from time import process_time
from rich import box
from rich.color import Color
from rich.console import Console, ConsoleOptions, Group, RenderableType, RenderResult
from rich.markdown import Markdown
from rich.measure import Measurement
from rich.pretty import Pretty
from rich.segment import... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/scope.py | rich/scope.py | 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... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/containers.py | rich/containers.py | from itertools import zip_longest
from typing import (
TYPE_CHECKING,
Iterable,
Iterator,
List,
Optional,
TypeVar,
Union,
overload,
)
if TYPE_CHECKING:
from .console import (
Console,
ConsoleOptions,
JustifyMethod,
OverflowMethod,
RenderResult... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_log_render.py | rich/_log_render.py | from datetime import datetime
from typing import Iterable, List, Optional, TYPE_CHECKING, Union, Callable
from .text import Text, TextType
if TYPE_CHECKING:
from .console import Console, ConsoleRenderable, RenderableType
from .table import Table
FormatTimeCallable = Callable[[datetime], Text]
class LogRen... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/traceback.py | rich/traceback.py | import inspect
import linecache
import os
import sys
from dataclasses import dataclass, field
from itertools import islice
from traceback import walk_tb
from types import ModuleType, TracebackType
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Sequence,
Set,
Tupl... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | true |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/prompt.py | rich/prompt.py | 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):
"""Exception base class for prompt relat... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/terminal_theme.py | rich/terminal_theme.py | from typing import List, Optional, Tuple
from .color_triplet import ColorTriplet
from .palette import Palette
_ColorTuple = Tuple[int, int, int]
class TerminalTheme:
"""A color theme used when exporting console content.
Args:
background (Tuple[int, int, int]): The background color.
foregrou... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/errors.py | rich/errors.py | class ConsoleError(Exception):
"""An error in console operation."""
class StyleError(Exception):
"""An error in styles."""
class StyleSyntaxError(ConsoleError):
"""Style was badly formatted."""
class MissingStyle(StyleError):
"""No such style."""
class StyleStackError(ConsoleError):
"""Style... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/theme.py | rich/theme.py | import configparser
from typing import IO, Dict, List, Mapping, Optional
from .default_styles import DEFAULT_STYLES
from .style import Style, StyleType
class Theme:
"""A container for style information, used by :class:`~rich.console.Console`.
Args:
styles (Dict[str, Style], optional): A mapping of s... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_pick.py | rich/_pick.py | from typing import Optional
def pick_bool(*values: Optional[bool]) -> bool:
"""Pick the first non-none bool or return the last value.
Args:
*values (bool): Any number of boolean or None values.
Returns:
bool: First non-none boolean.
"""
assert values, "1 or more values required"
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/jupyter.py | rich/jupyter.py | from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence
if TYPE_CHECKING:
from rich.console import ConsoleRenderable
from . import get_console
from .segment import Segment
from .terminal_theme import DEFAULT_TERMINAL_THEME
if TYPE_CHECKING:
from rich.console import ConsoleRenderable
JUPYTER_HT... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/logging.py | rich/logging.py | import logging
from datetime import datetime
from logging import Handler, LogRecord
from pathlib import Path
from types import ModuleType
from typing import ClassVar, Iterable, List, Optional, Type, Union
from rich._null_file import NullFile
from . import get_console
from ._log_render import FormatTimeCallable, LogRe... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/screen.py | rich/screen.py | from typing import Optional, TYPE_CHECKING
from .segment import Segment
from .style import StyleType
from ._loop import loop_last
if TYPE_CHECKING:
from .console import (
Console,
ConsoleOptions,
RenderResult,
RenderableType,
Group,
)
class Screen:
"""A renderabl... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.