Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ repos:
- id: detect-discord-bot-tokens

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.21.2
hooks:
- id: pyupgrade
args: ["--py310-plus"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand Down Expand Up @@ -47,24 +47,24 @@ repos:
- id: python-use-type-annotations
- id: text-unicode-replacement-char

- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 9.0.2
hooks:
- id: isort

- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
rev: v2.4.0
hooks:
- id: autoflake
args: ["-i", "--remove-all-unused-imports", "--remove-unused-variables"]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.4.1
hooks:
- id: flake8
args: ["--ignore=E203,W503", "--max-line-length=88"]
Expand All @@ -76,31 +76,31 @@ repos:
additional_dependencies: ["tomli"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v2.4.0
hooks:
- id: mypy
args: ["--ignore-missing-imports", "--show-error-codes"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: ["--print-width=88", "--prose-wrap=always"]
exclude: ^docs/internal/[a-z-]+\.md$

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.4.2
rev: v1.5.6
hooks:
- id: remove-tabs

- repo: https://github.com/sirosen/texthooks
rev: 0.5.0
rev: 0.7.1
hooks:
- id: fix-smartquotes
- id: fix-spaces

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.21.0
rev: 0.38.2
hooks:
- id: check-github-workflows
- id: check-renovate
Expand Down
1 change: 1 addition & 0 deletions botstrap/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module is an entry point for Botstrap's standalone CLI: `python -m botstrap`."""

from __future__ import annotations

from botstrap import cli
Expand Down
1 change: 1 addition & 0 deletions botstrap/cli/init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains functions used by the `botstrap init` standalone CLI command."""

from __future__ import annotations

import re
Expand Down Expand Up @@ -173,7 +174,7 @@
"""Opens the given url (must be https) and returns its contents as a str."""
if not url.startswith("https://"):
raise ValueError(f"File URL must start with 'https': {url}")
return urlopen(url, timeout=10).read().decode()

Check warning on line 177 in botstrap/cli/init.py

View check run for this annotation

codefactor.io / CodeFactor

botstrap/cli/init.py#L177

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected. (B310)

def get_file_contents(source_path: str) -> str:
"""Fetches and returns the file template with all placeholders filled in."""
Expand Down
1 change: 1 addition & 0 deletions botstrap/cli/menu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the entry point and main menu for Botstrap's standalone CLI."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions botstrap/cli/scan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains functions used by the `botstrap scan` standalone CLI command."""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions botstrap/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains general utility functions for the `botstrap` standalone CLI."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions botstrap/colors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains `Color` & `CliColors`, both of which add color to CLI output."""

from __future__ import annotations

from collections.abc import Callable
Expand Down
1 change: 1 addition & 0 deletions botstrap/flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module features the `Botstrap` class, which is the primary integration point."""

from __future__ import annotations

from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions botstrap/internal/argstrap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `Argstrap` class, which parses arguments for a bot's CLI."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions botstrap/internal/clisession.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `CliSession` class, which facilitates command-line I/O."""

from __future__ import annotations

from collections.abc import Callable
Expand Down
1 change: 1 addition & 0 deletions botstrap/internal/metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `Metadata` class, which provides metadata-related utils."""

from __future__ import annotations

import sys
Expand Down
3 changes: 2 additions & 1 deletion botstrap/internal/secrets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `Secret` class, which encrypts and decrypts data files."""

from __future__ import annotations

import os
Expand Down Expand Up @@ -120,7 +121,7 @@ def _get_storage_dir(storage_directory: str | Path | None) -> Path:

@staticmethod
def _get_validator(
valid_pattern: str | re.Pattern | Callable[[str], Any] | None
valid_pattern: str | re.Pattern | Callable[[str], Any] | None,
) -> Callable[[str], bool]:
"""Turns `valid_pattern` into a function that takes a str and returns a bool."""
if not valid_pattern:
Expand Down
1 change: 1 addition & 0 deletions botstrap/internal/tokens.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `Token` class, which represents a Discord bot token."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions botstrap/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `Option` class, which is a model for custom CLI options."""

from __future__ import annotations

import argparse
Expand Down
10 changes: 4 additions & 6 deletions botstrap/strings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the `CliStrings` class, which defines text shown in the CLI."""

from __future__ import annotations

from collections.abc import Callable, Iterable
Expand Down Expand Up @@ -306,18 +307,15 @@ def get_affirmation_prompt(


@overload
def _get_compact_value(value: str) -> str:
...
def _get_compact_value(value: str) -> str: ...


@overload
def _get_compact_value(value: Template) -> Template:
...
def _get_compact_value(value: Template) -> Template: ...


@overload
def _get_compact_value(value: tuple[str]) -> tuple[str, ...]:
...
def _get_compact_value(value: tuple[str]) -> tuple[str, ...]: ...


def _get_compact_value(value: Any) -> str | Template | tuple[str, ...]:
Expand Down
3 changes: 1 addition & 2 deletions docs/stylesheets/getting-started.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** Adjust the vertical alignment of inline badge images from shields.io. */
img[src^="https://img.shields.io/"]
{
img[src^="https://img.shields.io/"] {
margin-top: -0.125em;
vertical-align: text-top;
}
Expand Down
4 changes: 3 additions & 1 deletion docs/stylesheets/material.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
display: block;
margin: 0;
padding: 0.8rem;
transition: border 0.25s, box-shadow 0.25s;
transition:
border 0.25s,
box-shadow 0.25s;
}

.md-typeset .grid.cards > :is(ul, ol) > li:is(:focus-within, :hover),
Expand Down
1 change: 0 additions & 1 deletion examples/examplebot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from discord import Activity, ActivityType, AllowedMentions
from examplebot.extras import AlphaBot, initialize_system_logging


botstrap = (
Botstrap(
name="examplebot",
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/cli/test_init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.cli.init` module."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/cli/test_menu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.cli.menu` module."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/cli/test_scan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.cli.scan` module."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/cli/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.cli.utils` module."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/internal/test_argstrap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.internal.argstrap` module."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/internal/test_clisession.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.internal.clisession` module."""

from __future__ import annotations

from collections.abc import Callable
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/internal/test_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.internal.metadata` module."""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/internal/test_secrets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.internal.secrets` module."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/internal/test_tokens.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.internal.tokens` module."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/test_colors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.colors` module (`Color` and `CliColors` classes)."""

from __future__ import annotations

from collections.abc import Callable
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/test_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.flow` module (`Botstrap` class)."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/test_options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.options` module (`Option` and `Option.Results` classes)."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/botstrap/test_strings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `botstrap.strings` module (`CliStrings` class)."""

from __future__ import annotations

from collections.abc import Callable
Expand Down
Loading