Skip to content

Commit

Permalink
Added more linters and removed more lint (landlab#1514)
Browse files Browse the repository at this point in the history
* remove import lint with isort

* upgrade to python 3.8+ syntax

* remove trailing whitespace, fix end of file, etc.

* add .nox folder to .gitnore

* simplify code identified with flake8-simplify

* remove auto-generated *.cpp files

* remove bugbear lint--mostly unused loop counters

* adjust flake8 defaults

* add additional pre-commit hooks to look for lint

* use cached_property instead of lru_cache because of memory leak

* remove mutable keyword default values

* update flake8 config

* add news fragments

* clean up the project .gitignore file

* fix files with mixed line endings
  • Loading branch information
mcflugen authored Dec 7, 2022
1 parent e05c8b4 commit 101c536
Show file tree
Hide file tree
Showing 327 changed files with 1,615 additions and 1,956 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@
Ask a question or submit an issue: https://github.com/landlab/landlab/issues
Landlab Slack channel: https://landlab.slack.com
-->

1 change: 0 additions & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ jobs:
echo "Please see https://landlab.readthedocs.io/en/master/development/contribution/index.html?highlight=towncrier#news-entries for guidance."
false
fi
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository

runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Show conda installation info
run: |
conda info
- name: Install dependencies
run: pip install nox

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ jobs:
- name: Upload distributions
run: |
twine upload --skip-existing wheelhouse/*.whl
54 changes: 8 additions & 46 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ coverage.xml
*.pot

# Sphinx documentation
docs/_build/
docs/build/

# Vim
*~
Expand All @@ -77,56 +77,18 @@ test-results.xml

*.synctex.gz

.hypothesis/

installfiles.txt
# installfiles.txt

# Ignore all .c files as, currently, they are all cython generated.
*.c
*.cpp

landlab/io/mysave.grid

docs/auto_grid_info__BCs.rst

docs/auto_grid_info__cells.rst

docs/auto_grid_info__corners.rst

docs/auto_grid_info__faces.rst

docs/auto_grid_info__grads.rst

docs/auto_grid_info__links.rst

docs/auto_grid_info__mappers.rst

docs/auto_grid_info__nodes.rst

docs/auto_grid_info__patches.rst

docs/auto_grid_info__subsets.rst

docs/auto_grid_info__surf.rst

docs/auto_grid_info__whole.rst

landlab/components/spatial_precip/Durations_summer.csv

landlab/components/spatial_precip/Durations_winter.csv

\.pytest_cache/README\.md

\.pytest_cache/v/cache/lastfailed

\.pytest_cache/v/cache/nodeids


\.pytest_cache/v/cache/

docs/build_log.txt

.eggs/README.txt
# pytest
.pytest_cache/


# Hypothesis
.hypothesis

# nox virtual envs
.nox
56 changes: 48 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,60 @@ repos:
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies:
- flake8-comprehensions
# - flake8-bugbear
# - flake8-simplify
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-simplify

- repo: https://gitlab.com/iamlikeme/nbhooks
rev: 1.0.0
- repo: https://gitlab.com/kennon.mckeever/nbhooks
rev: 1.0.1
hooks:
- id: nb-ensure-clean
name: nb-ensure-clean
description: Ensure that committed Jupyter notebooks contain no outputs.
entry: nb-ensure-clean
files: \.ipynb$
language: python
language_version: python3.8

- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
files: \.py$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace

# - repo: https://github.com/PyCQA/pydocstyle
# rev: 6.1.1
# hooks:
# - id: pydocstyle
# files: landlab/.*\.py$
# args:
# - --convention=numpy
# - --add-select=D417
# additional_dependencies: [".[toml]"]

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.982
# hooks:
# - id: mypy
# additional_dependencies: [types-all]
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Contributors
- `Shelby Ahrendt <https://github.com/shelbyahrendt>`_
- `Josh Wolpert <https://github.com/josh-wolpert>`_
- `Christopher Sheehan <https://github.com/Sheehace>`_
- `slundell123 <https://github.com/slundell123>`_
- `slundell123 <https://github.com/slundell123>`_
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ cff-version: "1.2.0"
message: "If you use this software, please cite it using these metadata."
abstract : "Landlab is an open-source Python-language package for numerical modeling of Earth surface dynamics."
type: software
authors:
authors:
-
family-names: Hutton
given-names: Eric
orcid: "https://orcid.org/0000-0002-5864-6459"
-
family-names: Barnhart
given-names: Katy
given-names: Katy
orcid: "https://orcid.org/0000-0001-5682-455X"
-
family-names: Hobley
Expand Down
2 changes: 1 addition & 1 deletion FUNDING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ by the following grants:
* A Collaborative NSF Frameworks proposal to University of Colorado (Greg Tucker,
`2104102 <https://www.nsf.gov/awardsearch/showAward?AWD_ID=2104102&HistoricalAwards=false>`_).
* A Collaborative NSF Facility proposal to University of Colorado (Greg Tucker,
`2148762 <https://www.nsf.gov/awardsearch/showAward?AWD_ID=2148762&HistoricalAwards=false>`_).
`2148762 <https://www.nsf.gov/awardsearch/showAward?AWD_ID=2148762&HistoricalAwards=false>`_).
5 changes: 1 addition & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Installation
.. start-install-release
In order to use *landlab* you will first need Python. While not
necessary, we recommend using the
necessary, we recommend using the
`Anaconda Python distribution <https://www.anaconda.com/distribution/>`_
as it provides a large number of third-party packages useful for
scientific computing.
Expand Down Expand Up @@ -302,6 +302,3 @@ During workshops and clinics, we sometimes use the
`Landlab Slack channel <https://landlab.slack.com>`_.

.. end-contact
5 changes: 2 additions & 3 deletions docs/fix_redirects.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# fix redirects
import os

import fileinput
import os

_SRC = "source"

with open("build/linkcheck/output.txt", "r") as f:
with open("build/linkcheck/output.txt") as f:
link_out = f.readlines()


Expand Down
2 changes: 1 addition & 1 deletion docs/source/changes.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.. include:: ../../CHANGES.rst
.. include:: ../../CHANGES.rst
2 changes: 1 addition & 1 deletion docs/source/citing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Citing Components

.. include:: ../../README.rst
:start-after: .. start-citing-components
:end-before: .. end-citing-components
:end-before: .. end-citing-components
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# landlab documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 23 17:33:31 2013.
Expand All @@ -12,11 +11,12 @@
# serve to show the default.

import os
import sys
import tomli
import pathlib
import sys
from datetime import date

import tomli

import landlab

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contact_us.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Contact

.. include:: ../../README.rst
:start-after: .. start-contact
:end-before: .. end-contact
:end-before: .. end-contact
2 changes: 1 addition & 1 deletion docs/source/development/contribution/recommendations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Recommendations
- Arguments and keyword arguments start with lower case letters.
- Keyword arguments have reasonable default values (and the grid is the only argument to ``__init__``.
- Can return or not return information. Some recommendations, Nothing, grid, or a ... or a calculated value.
- If possible, we recommend that components are unit agnostic.
- If possible, we recommend that components are unit agnostic.
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ and download the Microsoft Visual C++ compiler. In April 2019 this was done by
first downloading "Build Tools for Visual Studio". Then when installing Build
Tools there were options for what exactly should be installed. One of these was
the Visual Studio C++ compilers. Once installed, a restart was required and
landlab compiled as expected.
landlab compiled as expected.
2 changes: 1 addition & 1 deletion docs/source/getting_started/teach_yourself_landlab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Self-study course for learning to use Landlab in your research

This course is entirely hosted in our Jupyter notebook tutorials. Here is a
link to the `syllabus <https://mybinder.org/v2/gh/landlab/landlab/release?filepath=notebooks/tutorials/syllabus.ipynb>`_
on Binder.
on Binder.
10 changes: 4 additions & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ Landlab: A modular Earth Surface Dynamics modeling library
install/index
development/index
API Reference <reference/index>

.. toctree::
:caption: Useful Links
:maxdepth: 1
:hidden:

changes
contact_us
citing
funding
Contributors <authors>
License <license>
Used by <usedby>

..
.. toctree::
:caption: Documentation Outline
:maxdepth: 2
install/index
getting_started/index
user_guide/index
Expand All @@ -68,5 +68,3 @@ Landlab: A modular Earth Surface Dynamics modeling library
:ref:`here <tutorials>`. A subset of these notebooks are designed specifically
for the classroom. Information about them and how to set them up for classroom
use is described :ref:`on this page <teaching_tutorials>`.

7 changes: 3 additions & 4 deletions docs/source/install/environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ should stick with *pip*.
.. tab:: mamba

.. code-block:: bash
$ conda install mamba -c conda-forge
$ mamba create -n landlab
$ mamba activate landlab
.. tab:: conda

.. code-block:: bash
$ conda create -n landlab
$ conda activate landlab
.. tab:: venv

.. code-block:: bash
$ python -m venv .venv
$ source .venv/bin/activate
Expand All @@ -41,4 +41,3 @@ Helpful links on managing virtual environments:

* `conda environments <https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands>`_.
* `venv environments <https://docs.python.org/3/tutorial/venv.html>`_.

2 changes: 1 addition & 1 deletion docs/source/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

environments
update_uninstall
additional_resources
additional_resources
2 changes: 1 addition & 1 deletion docs/source/install/installing_python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ operating system. For instance, Dan's Macbook Pro shows ``python`` on the path::

On a PC, run ``python`` from your Command Prompt window. You should see a reference to anaconda when it is running.

If you *don't* see reference to your newly installed distribution or the file is not found, click :ref:`here <correcting_install_paths>` to resolve the problem.
If you *don't* see reference to your newly installed distribution or the file is not found, click :ref:`here <correcting_install_paths>` to resolve the problem.

Once you have installed a complete Python distribution on your machine, follow :ref:`these instructions <install>` to install Landlab.
2 changes: 1 addition & 1 deletion docs/source/install/rough_guide_to_python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ that file in your favourite text editor, and add at the end:
Restart the terminal again, and check the version number now. Should be
right! (You will probably also want to do something similar with ipython,
but DEJH didn't explore that...)
but DEJH didn't explore that...)

Installing pip
--------------
Expand Down
2 changes: 0 additions & 2 deletions docs/source/install/update_uninstall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ To uninstall *landlab*,
.. code-block:: bash
$ pip uninstall landlab
1 change: 0 additions & 1 deletion docs/source/reference/components/bedrock_landslider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ BedrockLandslider: Location and magnitude of episodic bedrock landsliding
:members:
:undoc-members:
:show-inheritance:

Loading

0 comments on commit 101c536

Please sign in to comment.