Skip to content

Commit

Permalink
Modernization complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
coddingtonbear committed Jun 28, 2020
1 parent 14eb894 commit 026ebe1
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ include/*
share/*
.tox/*
pip-selfcheck.json
env/*
.vscode/*
.mypy_cache/*
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
import_heading_internal=Internal packages
known_first_party=myfitnesspal
default_section=THIRDPARTY
sections=FUTURE,STDLIB,THIRDPARTY,INTERNAL,FIRSTPARTY,LOCALFOLDER
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
default_language_version:
python: python3
repos:
# Sort imports prior to black reformatting, to
# ensure black always takes prescedence
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: end-of-file-fixer
files: '.*\.py$'
- id: flake8
additional_dependencies:
- flake8-bugbear==19.3.0
- flake8-printf-formatting==1.1.0
- flake8-pytest==1.3
- flake8-pytest-style==0.1.3
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
hooks:
- id: mypy
args:
- --pretty
- --show-error-codes
- --show-error-context
- --ignore-missing-imports
6 changes: 4 additions & 2 deletions myfitnesspal/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
from datetime import datetime
from getpass import getpass
from typing import Dict

from dateutil.parser import parse as dateparse
from rich import print
Expand All @@ -12,8 +13,9 @@
get_password_from_keyring_or_interactive,
store_password_in_keyring,
)
from .types import CommandDefinition

COMMANDS = {}
COMMANDS: Dict[str, CommandDefinition] = {}

logger = logging.getLogger(__name__)

Expand All @@ -37,7 +39,7 @@ def command(desc, name=None, aliases=None):

def decorator(fn):
main_name = name if name else fn.__name__
command_details = {
command_details: CommandDefinition = {
"function": fn,
"description": desc,
"is_alias": False,
Expand Down
10 changes: 10 additions & 0 deletions myfitnesspal/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import Callable, List

from typing_extensions import TypedDict


class CommandDefinition(TypedDict):
function: Callable
description: str
is_alias: bool
aliases: List[str]
14 changes: 14 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
# https://github.com/ambv/black#line-length
max-line-length = 88
ignore =
E203, # E203: whitespace before ':' (defer to black)
E231, # E231: missing whitespace after ',' (defer to black)
E501, # E501: line length (defer to black)
W503, # W503: break before binary operators (defer to black)
A003, # A003: [builtins] allow class attributes to be named after builtins (e.g., `id`)

[pep8]
max-line-length = 88
ignore =
E701, # E701: multiple statements on one line (flags py3 inline type hints)

0 comments on commit 026ebe1

Please sign in to comment.