diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85000d20..990e3d40 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,14 +7,33 @@ on: jobs: check: if: github.event_name != 'pull_request' || github.head_ref != 'devel' - name: install runs-on: ubuntu-latest + name: check steps: - uses: actions/checkout@v2 - with: - fetch-depth: 0 - uses: actions/setup-python@v2 - - run: pip install . + - name: set PYSHA + run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: dependencies + run: pip install -U pre-commit + - uses: reviewdog/action-setup@v1 + - if: github.event_name != 'schedule' + name: comment + run: | + if [[ $EVENT == pull_request ]]; then + REPORTER=github-pr-review + else + REPORTER=github-check + fi + pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + EVENT: ${{ github.event_name }} + - run: pre-commit run -a --show-diff-on-failure test-os: if: github.event_name != 'pull_request' || github.head_ref != 'devel' strategy: diff --git a/.gitignore b/.gitignore index b45f8695..26e23084 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,24 @@ *.py[cod] - -# C extensions *.so +__pycache__/ +.ipynb_checkpoints/ # Packages /tqdm/_dist_ver.py /.eggs/ -/tqdm.egg-info +/*.egg*/ /build/ /dist/ /snapcraft.yaml -/tqdm_*_amd64.snap +/tqdm_*.snap /.dockerignore # Unit test / coverage reports -.tox/ -.coverage -.coverage.* -__pycache__/ -.pytest_cache/ - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# PyCharm -.idea - -# IPython -.ipynb_checkpoints - -# asv -.asv/ -benchmarks/*.py[co] +/.tox/ +/.coverage* +/coverage.xml +/.pytest_cache/ +/.asv/ # Sumbodules /wiki/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..80e973d3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +default_language_version: + python: python3 +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-toml + - id: check-merge-conflict + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: sort-simple-yaml + - id: trailing-whitespace + exclude: ^README.rst$ +- repo: local + hooks: + - id: metadata + name: Check metadata + language: system + entry: make testsetup + pass_filenames: false + - id: pytest + name: pytest quick + entry: pytest + args: ['-qq', '--durations=1', '-k=not slow'] + pass_filenames: false + types: [python] + language: python + additional_dependencies: + - numpy + - pandas + - pytest-timeout + - pytest-asyncio +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 17b4a317..f9ec0ea4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -123,8 +123,8 @@ Also consider `pip install`ing development utilities: ## Pre-commit Hook -It's probably a good idea to add `[python setup.py] make pre-commit` to -`.git/hooks/pre-commit` for convenient local sanity-checking. +It's probably a good idea to run `pre-commit install` for convenient local +sanity-checking. ## Semantic Versioning diff --git a/Makefile b/Makefile index 08ec9aed..ee13c560 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,6 @@ testtimer distclean coverclean - pre-commit prebuildclean clean toxclean @@ -112,11 +111,6 @@ distclean: @+make coverclean @+make prebuildclean @+make clean -pre-commit: - # quick sanity checks - @make --no-print-directory testsetup - flake8 -j 8 --count --statistics setup.py .meta/ tqdm/ tests/ examples/ - pytest -qq --durations=1 -k "not slow" prebuildclean: @+python -c "import shutil; shutil.rmtree('build', True)" @+python -c "import shutil; shutil.rmtree('dist', True)" diff --git a/environment.yml b/environment.yml index ebe42d84..3bca86c8 100644 --- a/environment.yml +++ b/environment.yml @@ -12,6 +12,7 @@ dependencies: - setuptools_scm - toml # test env managers +- pre-commit - tox - asv # tests (native) diff --git a/setup.cfg b/setup.cfg index bbb055c3..4780c2f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,50 +1,23 @@ -[bdist_wheel] -universal = 1 - -[flake8] -ignore = W503,W504,E722 -max_line_length = 88 -exclude = .asv,.eggs,.tox,.ipynb_checkpoints,build,dist,.git,__pycache__ - -[yapf] -coalesce_brackets=True -column_limit=88 -each_dict_entry_on_separate_line=False -i18n_comment=NOQA -space_between_ending_comma_and_closing_bracket=False -split_before_named_assigns=False -split_before_closing_bracket=False - -[tool:pytest] -timeout=30 -log_level=INFO -markers= - asyncio - slow -python_files=tests_*.py -testpaths=tests -addopts=-v --tb=short -rxs -W=error --durations=0 --durations-min=0.1 - [metadata] -name = tqdm -url = https://github.com/tqdm/tqdm -project_urls = - Changelog = https://tqdm.github.io/releases - Documentation = https://github.com/tqdm/tqdm#tqdm - Documentation (dev) = https://tqdm.github.io/docs/tqdm - Wiki = https://github.com/tqdm/tqdm/wiki -maintainer = tqdm developers -maintainer_email = python.tqdm@gmail.com -license = MPLv2.0, MIT Licences -license_file = LICENCE -description = Fast, Extensible Progress Meter -long_description = file: README.rst -long_description_content_type = text/x-rst -keywords = progressbar, progressmeter, progress, bar, meter, rate, eta, console, terminal, time -platforms = any -provides = tqdm +name=tqdm +url=https://github.com/tqdm/tqdm +project_urls= + Changelog=https://tqdm.github.io/releases + Documentation=https://github.com/tqdm/tqdm#tqdm + Documentation (dev)=https://tqdm.github.io/docs/tqdm + Wiki=https://github.com/tqdm/tqdm/wiki +maintainer=tqdm developers +maintainer_email=python.tqdm@gmail.com +license=MPLv2.0, MIT Licences +license_file=LICENCE +description=Fast, Extensible Progress Meter +long_description=file: README.rst +long_description_content_type=text/x-rst +keywords=progressbar, progressmeter, progress, bar, meter, rate, eta, console, terminal, time +platforms=any +provides=tqdm # Trove classifiers (https://pypi.org/pypi?%3Aaction=list_classifiers) -classifiers = +classifiers= Development Status :: 5 - Production/Stable Environment :: Console Environment :: MacOS X @@ -101,16 +74,47 @@ classifiers = Topic :: Terminals Topic :: Utilities [options] -setup_requires = setuptools>=42; setuptools_scm[toml]>=3.4 -python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* -tests_require = pytest; flake8; coverage -include_package_data = True -packages = find: +setup_requires=setuptools>=42; setuptools_scm[toml]>=3.4 +python_requires=>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* +tests_require=pytest; flake8; coverage +include_package_data=True +packages=find: [options.extras_require] dev=py-make>=0.1.0; twine; wheel telegram=requests [options.entry_points] -console_scripts = - tqdm = tqdm.cli:main +console_scripts= + tqdm=tqdm.cli:main [options.packages.find] -exclude = benchmarks, tests +exclude=benchmarks, tests + +[bdist_wheel] +universal=1 + +[flake8] +ignore=W503,W504,E722 +max_line_length=88 +exclude=.asv,.eggs,.tox,.ipynb_checkpoints,build,dist,.git,__pycache__ + +[yapf] +coalesce_brackets=True +column_limit=88 +each_dict_entry_on_separate_line=False +i18n_comment=NOQA +space_between_ending_comma_and_closing_bracket=False +split_before_named_assigns=False +split_before_closing_bracket=False + +[isort] +multi_line_output=4 +known_first_party=tqdm,tests + +[tool:pytest] +timeout=30 +log_level=INFO +markers= + asyncio + slow +python_files=tests_*.py +testpaths=tests +addopts=-v --tb=short -rxs -W=error --durations=0 --durations-min=0.1