Skip to content

Commit

Permalink
chore: update docstrings (#132)
Browse files Browse the repository at this point in the history
* ci(deps): update pre-commit hooks
* fix(deps): update dependencies
* chore: update docstrings
  • Loading branch information
DeadNews authored Sep 11, 2023
1 parent 90444aa commit 44fe8e6
Show file tree
Hide file tree
Showing 10 changed files with 725 additions and 274 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
rev: v3.0.3
hooks:
- id: prettier

- repo: https://github.com/crate-ci/typos
rev: v1.16.8
rev: v1.16.11
hooks:
- id: typos

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.1
rev: 0.26.3
hooks:
- id: check-github-workflows
- id: check-renovate

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.286
rev: v0.0.288
hooks:
- id: ruff
args: [--fix]

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

Expand Down
296 changes: 143 additions & 153 deletions poetry.lock

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ images-upload-cli = "images_upload_cli.cli:cli"

[tool.poetry.dependencies]
python = "^3.9"
click = "^8.1.3"
httpx = "^0.24.1"
click = "^8.1.7"
httpx = "^0.25.0"
pillow = "^10.0.0"
pyperclip = "^1.8.2"
python-dotenv = "^1.0.0"

[tool.poetry.group.lint.dependencies]
black = "^23.7.0"
black = "^23.9.1"
mypy = "^1.5.1"
poethepoet = "^0.22.0"
ruff = "^0.0.286"
poethepoet = "^0.22.1"
ruff = "^0.0.288"

[tool.poetry.group.test.dependencies]
pytest = "^7.4.0"
pytest = "^7.4.2"
pytest-asyncio = "^0.21.1"
pytest-benchmark = "^4.0.0"
pytest-cov = "^4.1.0"
pytest-httpx = "^0.23.1"
pytest-httpx = "^0.25.0"

[tool.poetry-dynamic-versioning]
enable = true
Expand Down Expand Up @@ -108,3 +108,6 @@ allow-dict-calls-with-keyword-arguments = false

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.pydocstyle]
convention = "google"
34 changes: 29 additions & 5 deletions src/images_upload_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,23 @@ def cli(
notify: bool,
clipboard: bool,
) -> None:
"""Upload images via APIs."""
# loading .env variables
"""
Upload images via APIs.
Args:
images (tuple[Path]): A tuple of `Path` objects representing the paths to the images to be uploaded.
hosting (str): The hosting service to use for image upload.
bbcode (bool): A boolean flag indicating whether to generate BBCode links for the uploaded images.
thumbnail (bool): A boolean flag indicating whether to generate thumbnail images for the uploaded images.
notify (bool): A boolean flag indicating whether to send desktop notifications.
clipboard (bool): A boolean flag indicating whether to copy the image links to the clipboard.
Returns:
None.
Prints the links to the uploaded images and optionally copies them to the clipboard and sends desktop notifications.
"""
load_dotenv(dotenv_path=get_config_path())

# async images upload
links = asyncio.run(
upload_images(
upload_func=UPLOAD[hosting],
Expand All @@ -55,7 +67,6 @@ def cli(
)
)

# out
links_str = " ".join(links)
click.echo(links_str)
if clipboard:
Expand All @@ -70,7 +81,20 @@ async def upload_images(
bbcode: bool,
thumbnail: bool,
) -> list[str]:
"""Upload images coroutine."""
"""
Upload images coroutine.
Args:
upload_func (Callable): A callable function that handles the actual image upload.
It takes an `httpx.AsyncClient` instance and the image data as input and returns a link to the uploaded image.
images (tuple[Path]): A tuple of `Path` objects representing the paths to the images to be uploaded.
bbcode (bool): A boolean flag indicating whether to generate BBCode links for the uploaded images.
thumbnail (bool): A boolean flag indicating whether to generate thumbnail images for the uploaded images.
Returns:
list[str]: A list of links to the uploaded images. If the `thumbnail` flag is set to True,
the list includes links to the thumbnail images.
"""
links = []

if thumbnail:
Expand Down
Loading

0 comments on commit 44fe8e6

Please sign in to comment.