Skip to content

Commit

Permalink
Linting (#179)
Browse files Browse the repository at this point in the history
* Add pre-commit.

* Remove pep8 dependency.

* Rename pre-commit.yaml.

* Re-lint code base.

* Requirements tidy.

* Update CHANGES deprecation message.

* Remove .gitattributes now Versioneer is gone.

* Update README.

* Add Cirrus lint task.

* Python container for Cirrus lint task.

* Temporary increase to Codecov tolerance.

* Revert "Temporary increase to Codecov tolerance."

This reverts commit 80b3c61.

* Temporarily disable Codecov patch failure to allow for Black changes.

* Pre-commit just perform checks, don't modify.
  • Loading branch information
trexfeathers authored Jun 22, 2021
1 parent 50e44d0 commit 0ca0921
Show file tree
Hide file tree
Showing 36 changed files with 2,049 additions and 1,637 deletions.
17 changes: 15 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ env:
CFUNITS_CACHE_BUILD: "0"
# Base environment conda packages to be installed
MAMBA_CACHE_PACKAGES: "pip conda-lock"
# Increment the build number to force new pip cache upload.
PIP_CACHE_BUILD: "0"


#
# Linting
#
lint_task:
auto_cancellation: true
container:
image: python:latest
cpu: 2
memory: 4G
name: "${CIRRUS_OS}: linting"
lint_script:
- python -m pip install --retries 3 pre-commit
- pre-commit run --all-files


#
Expand Down
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.0.1"
hooks:
# Prevent giant files from being committed.
- id: check-added-large-files
# Check whether files parse as valid Python.
- id: check-ast
# Check for file name conflicts on case-insensitive filesytems.
- id: check-case-conflict
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
- id: debug-statements
# Don't commit to main branch.
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: "21.6b0"
hooks:
- id: black
# Force black to run on whole repo, using settings from pyproject.toml
pass_filenames: false
args: ["--config=./pyproject.toml", "--check", "."]
- repo: https://github.com/PyCQA/flake8
rev: "3.9.2"
hooks:
# Run flake8.
- id: flake8
args: ["--config=./setup.cfg"]
- repo: https://github.com/pycqa/isort
rev: "5.8.0"
hooks:
- id: isort
name: isort
args: ["--filter-files", "--check"]
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This file is no longer updated and is provided for historical purposes only.
Please see docs/cf_units/src/whatsnew/ for a changelog.
Please see the Git history for a record of changes.


Release 1.4 (14 June 2013)
Expand Down
64 changes: 17 additions & 47 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -26,68 +26,38 @@ Installing from source
The latest cf-units source release is available from
https://github.com/SciTools/cf-units/releases.

cf-units makes use of cftime, cython, numpy, setuptools and udunits2.
These dependencies must be in place before you can successfully install
cf-units. Once you have satisfied the requirements detailed below,
extract the cf-units source package, change to the new directory, and enter::

python setup.py install
Build and runtime requirements
==============================
See the ``requirements/`` directory for the external packages you will need to
have installed before installing and running cf-units.

For non-standard locations, additional build lib & include paths
can be provided as per-usual at build_ext phase::
The recommended way to provision requirements is using Conda::

python setup.py build_ext -I/path/to/include -L/path/to/lib
python setup.py install
conda env create -f requirements/cf-units.yml

All requirements except ``udunits2`` are also available individually via PyPI::

Build and runtime requirements
==============================
These are external packages which you will need to have installed before
installing and running cf-units.
pip install numpy

Many of these packages are available in Linux package managers
Many of the packages are also available in Linux package managers
such as aptitude and yum. For example, it may be possible to install
Numpy using::

apt-get install python-numpy

If you are installing dependencies with a package manager on Linux,
you may need to install the development packages (look for a "-dev"
postfix) in addition to the core packages.

python 2.7 or later (https://www.python.org/)
cf-units is compatible with Python 2 and Python 3.

cftime 1.0.0 or later (https://unidata.github.io/cftime/)
Python package for decoding time units conforming to
Climate and Forecasting (CF) netCDF conventions.

cython (https://pypi.org/project/Cython/)
Optimising static compiler for Python and the extended Cython
programming language.
Installing cf-units
===================
Once you have satisfied the requirements detailed above, extract the cf-units
source package, change to the new directory, and enter::

numpy 1.14 or later (https://pypi.org/project/numpy/)
Python package for scientific computing including a powerful N-dimensional
array object.
pip install .

udunits2 2.2.26 or later (https://www.unidata.ucar.edu/downloads/udunits/index.jsp)
C library for units of physical quantities.

setuptools (https://pypi.org/project/setuptools/)
Python package for installing/removing python packages.


Optional
''''''''
These packages are required for the full cf-units test suite to run.

pep8 1.4.6* (https://pypi.org/project/pep8/)
Python package for software testing.

pytest (https://pypi.org/project/pytest/)
Python testing framework.
For non-standard locations, additional build lib & include paths
can be provided as per-usual at ``build_ext`` phase::

* Those packages have been tested with a specific build.
pip install --global-option=build_ext --global-option="-I/path/to/include2 --global-option="-L/path/to/lib" .


Custom site configuration
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ recursive-include cf_units *.py *.pxd *.pyx *.c
include cf_units/etc/site.cfg.template
include CHANGES COPYING COPYING.LESSER INSTALL
exclude cf_units/etc/site.cfg
graft requirements
74 changes: 27 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,40 @@
<h1 align="center" style="margin:1em;">
<a href="https://scitools.org.uk/cf-units/docs/latest/">cf-units</a>
</h1>

<h4 align="center">
Units of measure as defined by the Climate and Forecast (CF) metadata
conventions.
</h4>

<p align="center">
<!-- https://shields.io/ is a good source of these -->
<a href="https://anaconda.org/conda-forge/cf-units">
<img src="https://img.shields.io/conda/dn/conda-forge/cf-units.svg"
alt="conda-forge downloads" /></a>
<a href="https://github.com/SciTools/cf-units/releases">
<img src="https://img.shields.io/github/tag/SciTools/cf-units.svg"
alt="Latest version" /></a>
<a href="https://github.com/SciTools/cf-units/commits/master">
<img src="https://img.shields.io/github/commits-since/SciTools/cf-units/latest.svg"
alt="Commits since last release" /></a>
<a href="https://github.com/SciTools/cf-units/graphs/contributors">
<img src="https://img.shields.io/github/contributors/SciTools/cf-units.svg"
alt="# contributors" /></a>
<a href="https://cirrus-ci.com/github/SciTools/cf-units">
<img src="https://api.cirrus-ci.com/github/SciTools/cf-units.svg?branch=master"
alt="cirrus-ci" /></a>
<a href="https://codecov.io/gh/SciTools/cf-units">
<img src="https://codecov.io/gh/SciTools/cf-units/branch/master/graph/badge.svg?token=6LlYlyTUZG"
alt="Coverage Status" /></a>
<!-- <a href="https://zenodo.org/badge/latestdoi/5282596">
<img src="https://zenodo.org/badge/5282596.svg"
alt="zenodo" /></a> -->
</p>
<br>
# [cf-units](https://scitools.org.uk/cf-units/docs/latest/)

#### Units of measure as defined by the Climate and Forecast (CF) metadata conventions.

[comment]: # (https://shields.io/ is a good source of these)
[![Build Status](https://api.cirrus-ci.com/github/SciTools/cf-units.svg)](https://cirrus-ci.com/github/SciTools/cf-units)
[![Coverage Status](https://codecov.io/gh/SciTools/cf-units/branch/master/graph/badge.svg?token=6LlYlyTUZG)](https://codecov.io/gh/SciTools/cf-units)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/SciTools/cf-units/master.svg)](https://results.pre-commit.ci/latest/github/SciTools/cf-units/master)
,
[![conda-forge downloads](https://img.shields.io/conda/vn/conda-forge/cf-units?color=orange&label=conda-forge&logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/cf-units)
[![PyPI](https://img.shields.io/pypi/v/cf-units?color=orange&label=pypi&logo=python&logoColor=white)](https://pypi.org/project/cf-units/)
[![Latest version](https://img.shields.io/github/tag/SciTools/cf-units)](https://github.com/SciTools/cf-units/releases)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3723086.svg)](https://doi.org/10.5281/zenodo.3723086)
,
[![Black](https://img.shields.io/badge/code%20style-black-000000)](https://github.com/psf/black)
[![Flake8](https://img.shields.io/badge/lint-flake8-lightgrey)](https://github.com/PyCQA/flake8)
[![isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
,
[![Licence](https://img.shields.io/github/license/SciTools/cf-units)](COPYING)
[![Contributors](https://img.shields.io/github/contributors/SciTools/cf-units)](https://github.com/SciTools/cf-units/graphs/contributors)
[![Commits since last release](https://img.shields.io/github/commits-since/SciTools/cf-units/latest.svg)](https://github.com/SciTools/cf-units/commits/master)

# Table of contents

<!--
NOTE: toc auto-generated with https://github.com/jonschlinkert/markdown-toc
$> markdown-toc -i --bullets='-' README.md
NOTE: This entire README can be markdown linted with
[comment]:
# (NOTE: toc auto-generated with https://github.com/jonschlinkert/markdown-toc
$> markdown-toc -i --bullets='-' README.md)
[comment]:
# (This entire README can be markdown linted with
https://github.com/igorshubovych/markdownlint-cli
$ echo '{"no-inline-html": false}' > .markdownrc
$ markdownlint README.md
-->

<!-- toc -->
$ markdownlint README.md)

- [Overview](#overview)
- [Example](#example)
- [Get in touch](#get-in-touch)
- [Credits, copyright and license](#credits-copyright-and-license)

<!-- tocstop -->

## Overview

Units of measure as required by the Climate and Forecast (CF) metadata
Expand Down Expand Up @@ -81,7 +62,6 @@ Documentation can be found at <https://scitools.org.uk/cf-units/docs/latest/>.
[submit a GitHub issue](https://github.com/SciTools/cf-units/issues).
- Suggest features: see our [contributing guide](.github/CONTRIBUTING.md).


## Credits, copyright and license

cf-units is developed collaboratively under the SciTools umbrella.
Expand Down
Loading

0 comments on commit 0ca0921

Please sign in to comment.