Skip to content

Commit

Permalink
Merge pull request #685 from grahamgower/lint
Browse files Browse the repository at this point in the history
add pre-commit github action
  • Loading branch information
grahamgower committed Nov 7, 2020
2 parents 009235c + 257bf9d commit 78bef56
Show file tree
Hide file tree
Showing 64 changed files with 3,141 additions and 2,192 deletions.
17 changes: 1 addition & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ aliases:
- image: circleci/python:3.6-stretch
working_directory: &working_directory /home/circleci/stdpopsim
- &set_py_circleci_own
run:
run:
name: Set ownership of Python directories
command: |
sudo chown -R circleci:circleci /usr/local/bin
Expand Down Expand Up @@ -139,20 +139,6 @@ jobs:
- store_test_results:
path: xml

lint:
<<: *container_config
steps:
- checkout
- run:
name: Lint Python
command: |
pip install flake8
flake8 --version
- run:
name: Lint Python
command: |
flake8 --max-line-length 89 stdpopsim setup.py tests docs/_ext maintenance
docs:
<<: *container_config
steps:
Expand All @@ -178,7 +164,6 @@ workflows:
version: 2
build_and_test:
jobs:
- lint
- build-slim-lib
- build-deps
- build-pkg:
Expand Down
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report-issue-template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: Bug report
about: A problem with stdpopsim
title:
labels:
title:
labels:
assignees: ''

---
Expand All @@ -18,4 +18,3 @@ that reproduces the problem.*

**Suggested fixes:**
*If you have an idea of what's causing the problem or how to fix it, we'd like to hear it!*

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request-issue-template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Feature request
about: A suggestion for something to add to stdpopsim.
title:
title:
labels: enhancement
assignees: ''

Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pre-commit

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pre-commit:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0
17 changes: 13 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 20.8b1
hooks:
- id: black
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
rev: 3.8.4
hooks:
- id: flake8
args: [--config=.flake8]
- repo: https://github.com/asottile/blacken-docs
rev: v1.8.0
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
additional_dependencies: [black==20.8b1]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: mixed-line-ending
args: [--fix=lf]
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Additionally, community organizers are available to help community members engag

## 8. Addressing Grievances

If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify PopSim Consortium with a concise description of your grievance. Your grievance will be considered by the organizers.
If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify PopSim Consortium with a concise description of your grievance. Your grievance will be considered by the organizers.



Expand All @@ -81,7 +81,7 @@ Andrew Kern or Jerome Kelleher

## 11. License and attribution

The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/).
The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/).

Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please see the [documentation](https://stdpopsim.readthedocs.io/en/latest/) for

Click [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/popsim-consortium/stdpopsim/master?filepath=stdpopsim_example.ipynb) to start an interactive Jupyter Notebook and start playing with `stdpopsim` now!

If you use ``stdpopsim`` in your work, please cite our
If you use ``stdpopsim`` in your work, please cite our
[paper](https://elifesciences.org/articles/54967).
See [here](https://stdpopsim.readthedocs.io/en/latest/introduction.html#citations) for
full citation details.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ To start an interactive Jupyter Notebook and start playing with ``stdpopsim`` no
If you use ``stdpopsim`` in your work, please cite our
`manuscript <https://doi.org/10.1101/2019.12.20.885129>`_ .
See `here <https://stdpopsim.readthedocs.io/en/latest/introduction.html#citations>`__ for
full citation details.
full citation details.
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#

# You can set these variables from the command line.
SPHINXOPTS = -W
SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# JK: added this target so that "make" will build the HTML
html:
html:
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Put it first so that "make" without argument is like "make help".
Expand Down
30 changes: 19 additions & 11 deletions docs/_ext/speciescatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_target(self, tid):
target node and calling note_explicit_target are essential to allow
us to cross reference these targets from the rest of the documentation.
"""
target = nodes.target('', '', ids=[tid], names=[tid])
target = nodes.target("", "", ids=[tid], names=[tid])
self.state.document.note_explicit_target(target)
return target

Expand All @@ -59,8 +59,9 @@ def make_field_list(self, data):
for i, citation in enumerate(citations):
text = f"{citation.author}, {citation.year}"
para += nodes.reference(
internal=False, refuri=citation.doi, text=text)
if i != len(citations)-1:
internal=False, refuri=citation.doi, text=text
)
if i != len(citations) - 1:
para += nodes.Text("; ")
para += nodes.Text(")")

Expand All @@ -76,10 +77,16 @@ def species_summary(self, species):
("ID", species.id, None),
("Name", species.name, None),
("Common name", species.common_name, None),
("Generation time", species.generation_time,
species.generation_time_citations),
("Population size", species.population_size,
species.population_size_citations),
(
"Generation time",
species.generation_time,
species.generation_time_citations,
),
(
"Population size",
species.population_size,
species.population_size_citations,
),
]
return self.make_field_list(data)

Expand All @@ -98,7 +105,8 @@ def citation_list(self, citable):

para = nodes.paragraph(text=f"{citation.author}, {citation.year}. ")
para += nodes.reference(
internal=False, refuri=citation.doi, text=citation.doi)
internal=False, refuri=citation.doi, text=citation.doi
)
list_item += para
bullet_list += list_item
return bullet_list
Expand Down Expand Up @@ -421,7 +429,7 @@ def setup(app):
app.add_directive("speciescatalog", SpeciesCatalogDirective)

return {
'version': '0.1',
'parallel_read_safe': True,
'parallel_write_safe': True,
"version": "0.1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
2 changes: 1 addition & 1 deletion docs/catalog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and saves the output to a file called ``test.trees``:
$ stdpopsim HomSap -c chr22 -o test.trees -g HapMapII_GRCh37 -d OutOfAfrica_3G09 2 2 2
(To learn more about using ``stdpopsim`` via the command-line, read our
(To learn more about using ``stdpopsim`` via the command-line, read our
:ref:`tutorial <sec_cli_tute>` about it.)

Are there other well-known organisms, genetic maps or models that
Expand Down
2 changes: 1 addition & 1 deletion docs/cli_arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Command-line options
.. argparse::
:module: stdpopsim.cli
:func: stdpopsim_cli_parser
:prog: stdpopsim
:prog: stdpopsim

0 comments on commit 78bef56

Please sign in to comment.