From 3528317e688c50a954bb16151596a6dacd3edff9 Mon Sep 17 00:00:00 2001 From: Freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Sun, 27 Mar 2022 18:10:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20docstring=20linter:=20pydo?= =?UTF-8?q?cstyle=20#10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 1 + README.md | 2 +- cli/api.py | 11 ++++++----- cli/commands.py | 9 ++++++--- cli/main.py | 13 ++++--------- requirements-dev.txt | 1 + 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index e3c7d96..6fdcc86 100644 --- a/Makefile +++ b/Makefile @@ -24,4 +24,5 @@ clean: # Remove files not tracked in source control lint: # Lint code ${VIRTUAL_ENV}/bin/black --check --quiet cli/*.py ${VIRTUAL_ENV}/bin/flake8 --config=setup.cfg + ${VIRTUAL_ENV}/bin/pydocstyle ${VIRTUAL_ENV}/bin/pylint --rcfile=setup.cfg cli/*.py diff --git a/README.md b/README.md index 0fc4b47..5ccf487 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ python cli/run.py --help - [Topic branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows#_topic_branch) are used and named after issue's slug - Built with `Python 3.9` -- Code linting with [`flake8`](https://pypi.org/project/flake8/), [`pylint`](https://pypi.org/project/pylint) & [`black`](https://pypi.org/project/black) +- Code linting with [`flake8`](https://pypi.org/project/flake8/), [`pylint`](https://pypi.org/project/pylint), [`black`](https://pypi.org/project/black) & [pydocstyle](https://pypi.org/project/pydocstyle/). - Install development tools: * `pip install -r requirements-dev.txt` - A `Makefile` with tools : run `make help` to have a look diff --git a/cli/api.py b/cli/api.py index 036123e..9bdd0a5 100644 --- a/cli/api.py +++ b/cli/api.py @@ -1,13 +1,14 @@ -""" -API utilities -""" - +#!/usr/bin/env python3 +# coding:utf-8 +"""Strava's API helpers.""" from strava.api._helpers import client, url, json def post_activity(xargs): - """API call to create an activity""" + """Post an activity creation. + Activity creation is made only with parameters (no GPX file). + """ response = client.post(url=url("/activities"), data=xargs) if response.ok: diff --git a/cli/commands.py b/cli/commands.py index b4451e9..59e26b5 100644 --- a/cli/commands.py +++ b/cli/commands.py @@ -1,5 +1,8 @@ -""" -CLI commands +#!/usr/bin/env python3 +# coding:utf-8 +"""Manage CLI commands. + +Each function describes a CLI command. """ import datetime @@ -83,7 +86,7 @@ _ACTIVITY_COLUMNS = ("key", "value") @output_option() @login_required def post_create(**kwargs): - """Create an activity""" + """Create an activity (manually).""" xargs = { "name": kwargs["name"], "type": kwargs["activity_type"], diff --git a/cli/main.py b/cli/main.py index 9a98d1d..c1e713c 100644 --- a/cli/main.py +++ b/cli/main.py @@ -1,12 +1,10 @@ #!/usr/bin/env python3 # coding:utf-8 -""" -run.py: CLI launcher, just run it +"""Geostrapy CLI. -Add `geostrapy` commands to `strava-cli` +Share data related to physical activities over an API (geo-localized or not) +This module adds commands for `strava-cli` https://github.com/bwilczynski/strava-cli """ - - import click from strava.commands import ( @@ -20,10 +18,7 @@ from commands import post_create @click.group() def cli(): - """ - Share data related to physical activities over an API (geo-localized or not) - Add commands for `strava-cli` https://github.com/bwilczynski/strava-cli - """ + """Launch the CLI.""" cli.add_command(login) diff --git a/requirements-dev.txt b/requirements-dev.txt index a6d00fa..583e3e5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ black flake8 +pydocstyle pylint -- GitLab