diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..60b8e2f4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: Lint + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7] + + steps: + - uses: actions/checkout@v1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox + + - name: Lint + run: tox -e lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..66b10622 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.6, 3.7] + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + - uses: actions/checkout@v1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox + python -m pip install -e . + + - name: Unit tests + shell: bash + # Drop the dot: py3.7 -> py37 + run: | + tox -e py`echo ${{ matrix.python-version }} | tr -d .` + + - name: Test runs + run: | + pypistats --help + pypistats recent --help + + # TODO Upload to Codecov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 815f2dc1..6cb7aa1f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,19 @@ repos: hooks: - id: flake8 language_version: python3.7 + + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort + language_version: python3.7 + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.4.0 + hooks: + - id: python-check-blanket-noqa + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml diff --git a/README.md b/README.md index 5eb3dadd..6417ac95 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![PyPI downloads](https://img.shields.io/pypi/dm/pypistats.svg)](https://pypistats.org/packages/pypistats) [![Build Status](https://travis-ci.org/hugovk/pypistats.svg?branch=master)](https://travis-ci.org/hugovk/pypistats) [![Build Status](https://dev.azure.com/hugovk/hugovk/_apis/build/status/hugovk.pypistats?branchName=master)](https://dev.azure.com/hugovk/hugovk/_build/latest?definitionId=1?branchName=master) +[![Actions Status](https://github.com/hugovk/pypistats/workflows/test/badge.svg)](https://github.com/hugovk/pypistats/actions) [![codecov](https://codecov.io/gh/hugovk/pypistats/branch/master/graph/badge.svg)](https://codecov.io/gh/hugovk/pypistats) [![GitHub](https://img.shields.io/github/license/hugovk/pypistats.svg)](LICENSE.txt) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) diff --git a/example/example.py b/example/example.py index dbfc56de..967197e8 100644 --- a/example/example.py +++ b/example/example.py @@ -4,7 +4,7 @@ Example use of pypistats """ import argparse -from pprint import pprint # noqa +from pprint import pprint # noqa: F401 import pypistats diff --git a/setup.cfg b/setup.cfg index dcb6336c..e61f78a5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,3 +9,10 @@ license_file = LICENSE.txt [pycodestyle] max_line_length = 88 + +[tool:isort] +force_grid_wrap = 0 +include_trailing_comma = True +line_length = 88 +multi_line_output = 3 +use_parentheses = True diff --git a/src/pypistats/__init__.py b/src/pypistats/__init__.py index f0cdfef7..36f5a492 100644 --- a/src/pypistats/__init__.py +++ b/src/pypistats/__init__.py @@ -11,6 +11,7 @@ from pathlib import Path import pkg_resources + import requests from appdirs import user_cache_dir from pytablewriter import ( diff --git a/src/pypistats/cli.py b/src/pypistats/cli.py index f2a29649..6c02e6e0 100644 --- a/src/pypistats/cli.py +++ b/src/pypistats/cli.py @@ -6,9 +6,8 @@ import argparse from datetime import date, datetime -from dateutil.relativedelta import relativedelta - import pypistats +from dateutil.relativedelta import relativedelta cli = argparse.ArgumentParser() subparsers = cli.add_subparsers(dest="subcommand") diff --git a/tests/test_cli.py b/tests/test_cli.py index 0f5e2b9f..854bb1ef 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -7,7 +7,6 @@ import pytest from freezegun import freeze_time - from pypistats import cli diff --git a/tests/test_pypistats.py b/tests/test_pypistats.py index da7e6b8f..0977f126 100644 --- a/tests/test_pypistats.py +++ b/tests/test_pypistats.py @@ -8,9 +8,8 @@ import unittest from pathlib import Path -import requests_mock - import pypistats +import requests_mock from .data.python_minor import DATA as PYTHON_MINOR_DATA diff --git a/tests/test_pypistats_cache.py b/tests/test_pypistats_cache.py index ab7ddb19..9d61c32f 100644 --- a/tests/test_pypistats_cache.py +++ b/tests/test_pypistats_cache.py @@ -7,11 +7,10 @@ import unittest from pathlib import Path +import pypistats import requests_mock from freezegun import freeze_time -import pypistats - class TestPypiStatsCache(unittest.TestCase): def setUp(self):