Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add isort hook; run pre-commit hooks w/ GitHub Actions #104

Merged
merged 4 commits into from
Feb 23, 2022
Merged
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
26 changes: 13 additions & 13 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ jobs:
name: Run unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Static code checking with pyflakes
run: |
pip3 install ".[all]"
pyflakes src
- name: Run unit tests
run: |
pytest
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Static code checks with pre-commit hooks
run: |
pip3 install ".[all]"
pre-commit run --all-files
- name: Run unit tests
run: |
pytest
28 changes: 14 additions & 14 deletions .github/workflows/unittests_with_codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ jobs:
name: Run unit tests with codecov upload
runs-on: ${{ matrix.os }}
env:
USING_COVERAGE: '3.7'
USING_COVERAGE: "3.7"
strategy:
matrix:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Static code checking with pyflakes
run: |
pip3 install ".[all]"
pyflakes src
- name: Generate coverage report
run: |
pytest
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Static code checks with pre-commit hooks
run: |
pip3 install ".[all]"
pre-commit run --all-files
- name: Generate coverage report
run: |
pytest
51 changes: 27 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
repos:
- repo: local
hooks:
- id: black
name: black
entry: black
language: python
types: [python]
language_version: python3.8
args: [--line-length=120]
- id: black
name: black
entry: black
language: python
types: [python]
language_version: python3.8
args: [--line-length, &line_length "120"]
- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
args: [--ignore-missing-imports, --namespace-packages, --show-error-codes, --pretty]
- id: isort
name: isort
entry: isort
language: system
types: [python]
args:
[
--profile=black,
--check-only,
--line-length,
*line_length,
--project,
KNOWN_FIRST_PARTY=doing,
]
- repo: local
hooks:
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
args: [--max-line-length=120, --docstring-convention=google, "--ignore=D100,D104,D212,D200,E203,W293,D412,W503"]
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
args: [--max-line-length, *line_length, "--ignore=D100,D104,W503"]
# D100 requires all Python files (modules) to have a "public" docstring even if all functions within have a docstring.
# D104 requires __init__ files to have a docstring
# D212
# D200
# D412 No blank lines allowed between a section header and its content
# E203
# W293 blank line contains whitespace
# W503 line break before binary operator (for compatibility with black)
24 changes: 16 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import codecs
import os.path
from setuptools import setup, find_packages

from setuptools import find_packages, setup


def read(rel_path):
"""
Read a file.
"""
"""Read a file."""
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), "r") as fp:
return fp.read()


def get_version(rel_path):
"""
Read version from a file.
"""
"""Read version from a file."""
for line in read(rel_path).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
Expand All @@ -30,7 +27,18 @@ def get_version(rel_path):


base_packages = ["Click>=8.0.1", "rich>=10.3.0", "pyyaml>=5.4.1", "timeago>=1.0.15", "psutil>=5.8.0"]
dev = ["mkdocs-material>=7.1", "mkdocs-macros-plugin", "pytest", "pytest-cov", "pytest-mock", "pyflakes"]
dev = [
"mkdocs-material>=7.1",
"mkdocs-macros-plugin",
"pytest",
"pytest-cov",
"pytest-mock",
"pre-commit",
"black",
"flake8",
"mypy",
"isort",
]

setup(
name="doing-cli",
Expand Down
10 changes: 5 additions & 5 deletions src/doing/cli.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import click
import collections
import os

import click
from rich.console import Console

from doing.pr import commands as pr_group
from doing import __version__
from doing.init import commands as init_command
from doing.issue import commands as issue_group
from doing.open import commands as open_group
from doing.list import commands as list_command
from doing.open import commands as open_group
from doing.pr import commands as pr_group
from doing.utils import get_config
from doing.workon import commands as workon_command
from doing.init import commands as init_command
from doing import __version__

console = Console()

Expand Down
8 changes: 5 additions & 3 deletions src/doing/init/_init.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from doing.utils import run_command
from rich.console import Console
import os
import yaml
from urllib.parse import urlparse

import yaml
from rich.console import Console

from doing.utils import run_command

console = Console()


Expand Down
7 changes: 3 additions & 4 deletions src/doing/issue/commands.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import click
from rich.console import Console

from doing.issue.create_issue import cmd_create_issue
from doing.options import get_common_options, get_config
from doing.issue.open_issue import cmd_open_issue
from doing.utils import run_command
from doing.list.commands import list

from rich.console import Console
from doing.options import get_common_options, get_config
from doing.utils import run_command

console = Console()

Expand Down
6 changes: 3 additions & 3 deletions src/doing/issue/create_issue.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from doing.exceptions import InputError
from doing.utils import replace_user_aliases, run_command, get_az_devop_user_email, validate_work_item_type

from rich.console import Console

from doing.exceptions import InputError
from doing.utils import get_az_devop_user_email, replace_user_aliases, run_command, validate_work_item_type

console = Console()


Expand Down
4 changes: 3 additions & 1 deletion src/doing/issue/open_issue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Union

import click

from doing.utils import get_config
from typing import Union


def cmd_open_issue(work_item_id: Union[str, int]) -> None:
Expand Down
10 changes: 5 additions & 5 deletions src/doing/list/_list.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import timeago
import datetime
from datetime import timezone
from typing import Dict, List

from doing.utils import run_command, get_repo_name, replace_user_aliases, validate_work_item_type
from rich.table import Table
import timeago
from rich.console import Console
from rich.live import Live
from rich.progress import track
from rich.console import Console
from rich.table import Table

from typing import List, Dict
from doing.utils import get_repo_name, replace_user_aliases, run_command, validate_work_item_type

console = Console()

Expand Down
5 changes: 3 additions & 2 deletions src/doing/list/commands.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import click
from urllib.parse import quote

from doing.options import get_common_options
import click

from doing.list._list import cmd_list, work_item_query
from doing.options import get_common_options
from doing.utils import get_config


Expand Down
5 changes: 3 additions & 2 deletions src/doing/open/commands.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import click
import os
from rich.console import Console
from urllib.parse import quote

import click
from rich.console import Console

from doing.issue.open_issue import cmd_open_issue
from doing.list._list import work_item_query
from doing.options import get_config
Expand Down
7 changes: 4 additions & 3 deletions src/doing/pr/commands.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import click
from rich.console import Console
from doing.pr.list_pr import cmd_list_pr
from doing.utils import get_config, run_command, get_repo_name, shell_output

from doing.open import commands as open_group
from doing.options import get_common_options
from doing.pr.create_pr import cmd_create_pr
from doing.pr.list_pr import cmd_list_pr
from doing.pr.open_pr import cmd_open_pr
from doing.open import commands as open_group
from doing.utils import get_config, get_repo_name, run_command, shell_output

console = Console()

Expand Down
12 changes: 6 additions & 6 deletions src/doing/pr/create_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import subprocess
import sys

from rich.console import Console

from doing.utils import (
get_az_devop_user_email,
get_config,
get_git_current_branch,
get_repo_name,
remove_special_chars,
replace_user_aliases,
run_command,
get_repo_name,
to_snake_case,
remove_special_chars,
get_az_devop_user_email,
get_git_current_branch,
)

from rich.console import Console

console = Console()


Expand Down
8 changes: 4 additions & 4 deletions src/doing/pr/list_pr.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import timeago
import datetime
from datetime import timezone

from doing.utils import get_repo_name, replace_user_aliases, run_command

from rich.table import Table
import timeago
from rich.console import Console
from rich.table import Table

from doing.utils import get_repo_name, replace_user_aliases, run_command

console = Console()

Expand Down
7 changes: 4 additions & 3 deletions src/doing/pr/open_pr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import click
from doing.utils import get_config
from doing.utils import get_repo_name
from typing import Union

import click

from doing.utils import get_config, get_repo_name


def cmd_open_pr(pullrequest_id: Union[str, int]) -> None:
"""
Expand Down
20 changes: 9 additions & 11 deletions src/doing/utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import os
import sys
import json
import yaml
import os
import re
import string
import psutil

from platform import uname
from rich.console import Console
import subprocess
from typing import Dict, Union, Text, Iterator
import sys
from collections import OrderedDict
from functools import lru_cache
from platform import uname
from typing import Dict, Iterator, Text, Union

from doing.exceptions import ConfigurationError, devops_error_tips

import psutil
import yaml
from rich.console import Console
from rich.traceback import install

from functools import lru_cache
from doing.exceptions import ConfigurationError, devops_error_tips

install()
console = Console()
Expand Down
Loading