Skip to content

Commit a082071

Browse files
authored
Merge pull request #117 from apriha/feature/lint-and-format-with-ruff
Lint and format with Ruff
2 parents 54d0219 + 78cfb3e commit a082071

17 files changed

+898
-1002
lines changed

.github/workflows/ci.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@ jobs:
2525
- name: Enable workflow based on preconditions
2626
run: echo "Workflow enabled."
2727

28-
lint:
28+
lint-format:
2929
needs: [enable-workflow]
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v4
3333
- uses: actions/setup-python@v5
3434
with:
3535
python-version: '3.12'
36-
- name: Install Black
36+
- name: Install Ruff
3737
run: |
38-
pip install black
39-
- name: Lint with Black
38+
pip install ruff
39+
- name: Lint with Ruff
4040
run: |
41-
black --check --diff .
41+
ruff check
42+
- name: Format with Ruff
43+
run: |
44+
ruff format --check
4245
4346
build-docs:
4447
needs: [enable-workflow]
@@ -57,7 +60,7 @@ jobs:
5760
sphinx-build -W --keep-going -T -E -D language=en docs docs/_build
5861
5962
test:
60-
needs: [lint, build-docs]
63+
needs: [lint-format, build-docs]
6164
runs-on: ${{ matrix.os }}
6265
strategy:
6366
matrix:

CONTRIBUTING.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ To set up ``lineage`` for local development:
6565
.. note:: After running the tests, a coverage report can be viewed by opening
6666
``htmlcov/index.html`` in a browser.
6767

68-
6. Check code formatting::
68+
6. Perform code linting and formatting::
6969

70-
$ pipenv run black --check --diff .
70+
$ pipenv run ruff check --fix
71+
$ pipenv run ruff format
7172

7273
7. Commit your changes and push your branch to GitHub::
7374

Pipfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pytest = "*"
88
pytest-cov = "*"
99
sphinx = "*"
1010
sphinx-rtd-theme = "*"
11-
black = "*"
11+
ruff = "*"
1212

1313
[packages]
1414
lineage = {editable = true,path = "."}

Pipfile.lock

+745-724
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. image:: https://raw.githubusercontent.com/apriha/lineage/master/docs/images/lineage_banner.png
22

3-
|ci| |codecov| |docs| |pypi| |python| |downloads| |license| |black|
3+
|ci| |codecov| |docs| |pypi| |python| |downloads| |license| |ruff|
44

55
lineage
66
=======
@@ -249,6 +249,10 @@ Thanks to Whit Athey, Ryan Dale, Binh Bui, Jeff Gill, Gopal Vashishtha,
249249
``lineage`` incorporates code and concepts generated with the assistance of
250250
`OpenAI's <https://openai.com>`_ `ChatGPT <https://chatgpt.com>`_ . ✨
251251

252+
License
253+
-------
254+
``lineage`` is licensed under the `MIT License <https://github.com/apriha/lineage/blob/master/LICENSE.txt>`_.
255+
252256
.. https://github.com/rtfd/readthedocs.org/blob/master/docs/badges.rst
253257
.. |ci| image:: https://github.com/apriha/lineage/actions/workflows/ci.yml/badge.svg?branch=master
254258
:target: https://github.com/apriha/lineage/actions/workflows/ci.yml
@@ -264,5 +268,6 @@ Thanks to Whit Athey, Ryan Dale, Binh Bui, Jeff Gill, Gopal Vashishtha,
264268
:target: https://pepy.tech/project/lineage
265269
.. |license| image:: https://img.shields.io/pypi/l/lineage.svg
266270
:target: https://github.com/apriha/lineage/blob/master/LICENSE.txt
267-
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
268-
:target: https://github.com/psf/black
271+
.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
272+
:target: https://github.com/astral-sh/ruff
273+
:alt: Ruff

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import sys
2222
from unittest.mock import MagicMock
2323

24+
import lineage
25+
2426
# http://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
2527
autodoc_mock_imports = [
2628
"numpy",
@@ -43,8 +45,6 @@ def __getattr__(cls, name):
4345
for mod_name in autodoc_mock_imports:
4446
sys.modules[mod_name] = Mock()
4547

46-
import lineage
47-
4848
# https://samnicholls.net/2016/06/15/how-to-sphinx-readthedocs/
4949

5050
# -- General configuration ------------------------------------------------

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[build-system]
22
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta:__legacy__"
3+
build-backend = "setuptools.build_meta:__legacy__"
4+
5+
# https://github.com/astral-sh/ruff/issues/465#issuecomment-1783684428
6+
[tool.ruff.lint]
7+
extend-select = ["I"]

setup.py

+22-55
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# Copyright (c) 2016 The Python Packaging Authority (PyPA)
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
# this software and associated documentation files (the "Software"), to deal in
5+
# the Software without restriction, including without limitation the rights to
6+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
# of the Software, and to permit persons to whom the Software is furnished to do
8+
# so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all
11+
# copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
# SOFTWARE.
20+
121
"""A setuptools based setup module.
222
323
See:
@@ -6,65 +26,12 @@
626
727
"""
828

9-
"""
10-
Copyright (c) 2016 The Python Packaging Authority (PyPA)
11-
12-
Permission is hereby granted, free of charge, to any person obtaining a copy of
13-
this software and associated documentation files (the "Software"), to deal in
14-
the Software without restriction, including without limitation the rights to
15-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
16-
of the Software, and to permit persons to whom the Software is furnished to do
17-
so, subject to the following conditions:
18-
19-
The above copyright notice and this permission notice shall be included in all
20-
copies or substantial portions of the Software.
21-
22-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28-
SOFTWARE.
29-
30-
"""
31-
32-
"""
33-
MIT License
34-
35-
Copyright (c) 2016 Andrew Riha
36-
37-
Permission is hereby granted, free of charge, to any person obtaining a copy
38-
of this software and associated documentation files (the "Software"), to deal
39-
in the Software without restriction, including without limitation the rights
40-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41-
copies of the Software, and to permit persons to whom the Software is
42-
furnished to do so, subject to the following conditions:
43-
44-
The above copyright notice and this permission notice shall be included in all
45-
copies or substantial portions of the Software.
46-
47-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53-
SOFTWARE.
54-
55-
"""
56-
5729
# To use a consistent encoding
5830
from codecs import open
5931
from glob import glob
60-
from os.path import abspath
61-
from os.path import basename
62-
from os.path import dirname
63-
from os.path import join
64-
from os.path import splitext
32+
from os.path import abspath, basename, dirname, join, splitext
6533

66-
from setuptools import find_packages
67-
from setuptools import setup
34+
from setuptools import find_packages, setup
6835

6936
import versioneer
7037

src/lineage/__init__.py

+2-27
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,13 @@
1-
""" lineage
1+
"""lineage
22
33
tools for genetic genealogy and the analysis of consumer DNA test results
44
55
"""
66

7-
"""
8-
MIT License
9-
10-
Copyright (c) 2016 Andrew Riha
11-
12-
Permission is hereby granted, free of charge, to any person obtaining a copy
13-
of this software and associated documentation files (the "Software"), to deal
14-
in the Software without restriction, including without limitation the rights
15-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16-
copies of the Software, and to permit persons to whom the Software is
17-
furnished to do so, subject to the following conditions:
18-
19-
The above copyright notice and this permission notice shall be included in all
20-
copies or substantial portions of the Software.
21-
22-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28-
SOFTWARE.
29-
30-
"""
31-
327
import datetime
33-
from itertools import chain, combinations
348
import logging
359
import os
10+
from itertools import chain, combinations
3611

3712
import numpy as np
3813
import pandas as pd

src/lineage/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"""Git implementation of _version.py."""
1212

1313
import errno
14+
import functools
1415
import os
1516
import re
1617
import subprocess
1718
import sys
1819
from typing import Any, Callable, Dict, List, Optional, Tuple
19-
import functools
2020

2121

2222
def get_keywords() -> Dict[str, str]:

src/lineage/individual.py

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
1-
""" Class for representing individuals within the `lineage` framework. """
1+
"""Class for representing individuals within the `lineage` framework."""
22

3-
"""
4-
MIT License
5-
6-
Copyright (c) 2016 Andrew Riha
7-
8-
Permission is hereby granted, free of charge, to any person obtaining a copy
9-
of this software and associated documentation files (the "Software"), to deal
10-
in the Software without restriction, including without limitation the rights
11-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12-
copies of the Software, and to permit persons to whom the Software is
13-
furnished to do so, subject to the following conditions:
14-
15-
The above copyright notice and this permission notice shall be included in all
16-
copies or substantial portions of the Software.
17-
18-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24-
SOFTWARE.
25-
26-
"""
273
import inspect
284

295
from snps import SNPs

src/lineage/resources.py

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Class for downloading and loading required external resources.
1+
"""Class for downloading and loading required external resources.
22
33
`lineage` uses tables and data from UCSC's Genome Browser:
44
@@ -29,31 +29,6 @@
2929
3030
"""
3131

32-
"""
33-
MIT License
34-
35-
Copyright (c) 2017 Andrew Riha
36-
37-
Permission is hereby granted, free of charge, to any person obtaining a copy
38-
of this software and associated documentation files (the "Software"), to deal
39-
in the Software without restriction, including without limitation the rights
40-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41-
copies of the Software, and to permit persons to whom the Software is
42-
furnished to do so, subject to the following conditions:
43-
44-
The above copyright notice and this permission notice shall be included in all
45-
copies or substantial portions of the Software.
46-
47-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53-
SOFTWARE.
54-
55-
"""
56-
5732
import logging
5833
import tarfile
5934

0 commit comments

Comments
 (0)