From 9b22d057f32ec5c2a11907a65f92250ba117b42f Mon Sep 17 00:00:00 2001 From: Thomas <43009897+thomas-reimonn@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:49:56 -0400 Subject: [PATCH 1/2] fix: add tqdm dependency (#57) --- .pre-commit-config.yaml | 10 ---------- pyproject.toml | 3 ++- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3aafe67..7f6504a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,16 +14,6 @@ repos: rev: 1.13.0 hooks: - id: blacken-docs - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.9-for-vscode - hooks: - - id: prettier - # Newer versions of node don't work on systems that have an older version of GLIBC - # (in particular Ubuntu 18.04 and Centos 7) - # EOL of Centos 7 is in 2024-06, we can probably get rid of this then. - # See https://github.com/scverse/cookiecutter-scverse/issues/143 and - # https://github.com/jupyterlab/jupyterlab/issues/12675 - language_version: "17.9.1" - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.0.262 hooks: diff --git a/pyproject.toml b/pyproject.toml index 7449e6a..6d7314e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,8 @@ dependencies = [ "pandas", "pyarrow", # for debug logging (referenced from the issue template) - "session-info" + "session-info", + "tqdm" ] [project.optional-dependencies] From a18e2fb88f23e8278485e6b23af630537cbf3d6a Mon Sep 17 00:00:00 2001 From: scverse-bot <108668866+scverse-bot@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:51:08 +0200 Subject: [PATCH 2/2] Update template to v0.3.1 (#56) * Update template to v0.3.1 * Fix .rej * Remove prettier * Fix install instructions in contributing.md * Apply formatting --------- Co-authored-by: scverse-bot Co-authored-by: Isaac Virshup --- .bumpversion.cfg | 8 - .codecov.yaml | 22 +- .cruft.json | 48 +-- .editorconfig | 6 + .github/ISSUE_TEMPLATE/bug_report.yml | 164 +++++----- .github/ISSUE_TEMPLATE/config.yml | 6 +- .github/ISSUE_TEMPLATE/feature_request.yml | 14 +- .github/workflows/build.yaml | 44 +-- .github/workflows/release.yaml | 29 ++ .github/workflows/sync.yaml | 46 --- .github/workflows/test.yaml | 96 +++--- .pre-commit-config.yaml | 68 ++-- .readthedocs.yaml | 22 +- docs/_static/css/custom.css | 4 + docs/conf.py | 18 +- docs/contributing.md | 82 ++--- docs/index.md | 1 - docs/make.bat | 35 -- docs/notebooks/basic_usage.ipynb | 29 +- docs/template_usage.md | 364 --------------------- pyproject.toml | 22 +- src/genomic_features/_core/filters.py | 2 +- tests/test_list_ensdb_annotations.py | 15 +- 23 files changed, 348 insertions(+), 797 deletions(-) delete mode 100644 .bumpversion.cfg create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/sync.yaml create mode 100644 docs/_static/css/custom.css delete mode 100644 docs/make.bat delete mode 100644 docs/template_usage.md diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index fdba9e4..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,8 +0,0 @@ -[bumpversion] -current_version = 0.0.1 -tag = True -commit = True - -[bumpversion:file:./pyproject.toml] -search = version = "{current_version}" -replace = version = "{new_version}" diff --git a/.codecov.yaml b/.codecov.yaml index 829e56c..d0c0e29 100644 --- a/.codecov.yaml +++ b/.codecov.yaml @@ -1,17 +1,17 @@ # Based on pydata/xarray codecov: - require_ci_to_pass: no + require_ci_to_pass: no coverage: - status: - project: - default: - # Require 1% coverage, i.e., always succeed - target: 1 - patch: false - changes: false + status: + project: + default: + # Require 1% coverage, i.e., always succeed + target: 1 + patch: false + changes: false comment: - layout: diff, flags, files - behavior: once - require_base: no + layout: diff, flags, files + behavior: once + require_base: no diff --git a/.cruft.json b/.cruft.json index 3ad4cf1..f44d9ec 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,23 +1,29 @@ { - "template": "https://github.com/scverse/cookiecutter-scverse", - "commit": "5f091ed0952e4adac0c95bda4006bec0b4532995", - "checkout": null, - "context": { - "cookiecutter": { - "project_name": "genomic-features", - "package_name": "genomic_features", - "project_description": "Genomic annotations using BioConductor resources in Python.", - "author_full_name": "Isaac Virshup", - "author_email": "ivirshup@gmail.com", - "github_user": "ivirshup", - "project_repo": "https://github.com/scverse/genomic-features", - "license": "BSD 3-Clause License", - "_copy_without_render": [ - ".github/workflows/**.yaml", - "docs/_templates/autosummary/**.rst" - ], - "_template": "https://github.com/scverse/cookiecutter-scverse" - } - }, - "directory": null + "template": "https://github.com/scverse/cookiecutter-scverse", + "commit": "586b1652162ff7994b0070a034023d64289ae416", + "checkout": "v0.3.1", + "context": { + "cookiecutter": { + "project_name": "genomic-features", + "package_name": "genomic_features", + "project_description": "Genomic annotations using BioConductor resources in Python.", + "author_full_name": "Isaac Virshup", + "author_email": "ivirshup@gmail.com", + "github_user": "ivirshup", + "project_repo": "https://github.com/scverse/genomic-features", + "license": "BSD 3-Clause License", + "_copy_without_render": [ + ".github/workflows/build.yaml", + ".github/workflows/test.yaml", + "docs/_templates/autosummary/**.rst" + ], + "_render_devdocs": false, + "_jinja2_env_vars": { + "lstrip_blocks": true, + "trim_blocks": true + }, + "_template": "https://github.com/scverse/cookiecutter-scverse" + } + }, + "directory": null } diff --git a/.editorconfig b/.editorconfig index 2fe0ce0..050f911 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,5 +8,11 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true +[*.{yml,yaml}] +indent_size = 2 + +[.cruft.json] +indent_size = 2 + [Makefile] indent_style = tab diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 8d3ddaa..a5a20e6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -2,88 +2,88 @@ name: Bug report description: Report something that is broken or incorrect labels: bug body: - - type: markdown - attributes: - value: | - **Note**: Please read [this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) - detailing how to provide the necessary information for us to reproduce your bug. In brief: - * Please provide exact steps how to reproduce the bug in a clean Python environment. - * In case it's not clear what's causing this bug, please provide the data or the data generation procedure. - * Sometimes it is not possible to share the data, but usually it is possible to replicate problems on publicly - available datasets or to share a subset of your data. + - type: markdown + attributes: + value: | + **Note**: Please read [this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) + detailing how to provide the necessary information for us to reproduce your bug. In brief: + * Please provide exact steps how to reproduce the bug in a clean Python environment. + * In case it's not clear what's causing this bug, please provide the data or the data generation procedure. + * Sometimes it is not possible to share the data, but usually it is possible to replicate problems on publicly + available datasets or to share a subset of your data. - - type: textarea - id: report - attributes: - label: Report - description: A clear and concise description of what the bug is. - validations: - required: true + - type: textarea + id: report + attributes: + label: Report + description: A clear and concise description of what the bug is. + validations: + required: true - - type: textarea - id: versions - attributes: - label: Version information - description: | - Please paste below the output of + - type: textarea + id: versions + attributes: + label: Version information + description: | + Please paste below the output of - ```python - import session_info - session_info.show(html=False, dependencies=True) - ``` - placeholder: | - ----- - anndata 0.8.0rc2.dev27+ge524389 - session_info 1.0.0 - ----- - asttokens NA - awkward 1.8.0 - backcall 0.2.0 - cython_runtime NA - dateutil 2.8.2 - debugpy 1.6.0 - decorator 5.1.1 - entrypoints 0.4 - executing 0.8.3 - h5py 3.7.0 - ipykernel 6.15.0 - jedi 0.18.1 - mpl_toolkits NA - natsort 8.1.0 - numpy 1.22.4 - packaging 21.3 - pandas 1.4.2 - parso 0.8.3 - pexpect 4.8.0 - pickleshare 0.7.5 - pkg_resources NA - prompt_toolkit 3.0.29 - psutil 5.9.1 - ptyprocess 0.7.0 - pure_eval 0.2.2 - pydev_ipython NA - pydevconsole NA - pydevd 2.8.0 - pydevd_file_utils NA - pydevd_plugins NA - pydevd_tracing NA - pygments 2.12.0 - pytz 2022.1 - scipy 1.8.1 - setuptools 62.5.0 - setuptools_scm NA - six 1.16.0 - stack_data 0.3.0 - tornado 6.1 - traitlets 5.3.0 - wcwidth 0.2.5 - zmq 23.1.0 - ----- - IPython 8.4.0 - jupyter_client 7.3.4 - jupyter_core 4.10.0 - ----- - Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) [GCC 10.3.0] - Linux-5.18.6-arch1-1-x86_64-with-glibc2.35 - ----- - Session information updated at 2022-07-07 17:55 + ```python + import session_info + session_info.show(html=False, dependencies=True) + ``` + placeholder: | + ----- + anndata 0.8.0rc2.dev27+ge524389 + session_info 1.0.0 + ----- + asttokens NA + awkward 1.8.0 + backcall 0.2.0 + cython_runtime NA + dateutil 2.8.2 + debugpy 1.6.0 + decorator 5.1.1 + entrypoints 0.4 + executing 0.8.3 + h5py 3.7.0 + ipykernel 6.15.0 + jedi 0.18.1 + mpl_toolkits NA + natsort 8.1.0 + numpy 1.22.4 + packaging 21.3 + pandas 1.4.2 + parso 0.8.3 + pexpect 4.8.0 + pickleshare 0.7.5 + pkg_resources NA + prompt_toolkit 3.0.29 + psutil 5.9.1 + ptyprocess 0.7.0 + pure_eval 0.2.2 + pydev_ipython NA + pydevconsole NA + pydevd 2.8.0 + pydevd_file_utils NA + pydevd_plugins NA + pydevd_tracing NA + pygments 2.12.0 + pytz 2022.1 + scipy 1.8.1 + setuptools 62.5.0 + setuptools_scm NA + six 1.16.0 + stack_data 0.3.0 + tornado 6.1 + traitlets 5.3.0 + wcwidth 0.2.5 + zmq 23.1.0 + ----- + IPython 8.4.0 + jupyter_client 7.3.4 + jupyter_core 4.10.0 + ----- + Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) [GCC 10.3.0] + Linux-5.18.6-arch1-1-x86_64-with-glibc2.35 + ----- + Session information updated at 2022-07-07 17:55 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 5cad625..5b62547 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - - name: Scverse Community Forum - url: https://discourse.scverse.org/ - about: If you have questions about “How to do X”, please ask them here. + - name: Scverse Community Forum + url: https://discourse.scverse.org/ + about: If you have questions about “How to do X”, please ask them here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index be51193..35f0493 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -2,10 +2,10 @@ name: Feature request description: Propose a new feature for genomic-features labels: enhancement body: - - type: textarea - id: description - attributes: - label: Description of feature - description: Please describe your suggestion for a new feature. It might help to describe a problem or use case, plus any alternatives that you have considered. - validations: - required: true + - type: textarea + id: description + attributes: + label: Description of feature + description: Please describe your suggestion for a new feature. It might help to describe a problem or use case, plus any alternatives that you have considered. + validations: + required: true diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3dffda6..8bba03e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,29 +1,29 @@ name: Check Build on: - push: - branches: [main] - pull_request: - branches: [main] + push: + branches: [main] + pull_request: + branches: [main] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: "3.11" - cache: "pip" - cache-dependency-path: "**/pyproject.toml" - - name: Install build dependencies - run: python -m pip install --upgrade pip wheel twine build - - name: Build package - run: python -m build - - name: Check package - run: twine check --strict dist/*.whl + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: "pip" + cache-dependency-path: "**/pyproject.toml" + - name: Install build dependencies + run: python -m pip install --upgrade pip wheel twine build + - name: Build package + run: python -m build + - name: Check package + run: twine check --strict dist/*.whl diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..5732c02 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: Release + +on: + release: + types: [published] + +# Use "trusted publishing", see https://docs.pypi.org/trusted-publishers/ +jobs: + release: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/genomic_features + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v4 + with: + filter: blob:none + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + cache: "pip" + - run: pip install build + - run: python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/sync.yaml b/.github/workflows/sync.yaml deleted file mode 100644 index 36471f2..0000000 --- a/.github/workflows/sync.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: Sync Template - -on: - workflow_dispatch: - schedule: - - cron: "0 2 * * *" # every night at 2:00 UTC - -jobs: - sync: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Install dependencies - # for now, pin cookiecutter version, due to https://github.com/cruft/cruft/issues/166 - run: python -m pip install --upgrade cruft "cookiecutter<2" pre-commit toml - - name: Find Latest Tag - uses: oprypin/find-latest-tag@v1.1.0 - id: get-latest-tag - with: - repository: scverse/cookiecutter-scverse - releases-only: false - sort-tags: true - regex: '^v\d+\.\d+\.\d+$' # vX.X.X - - name: Sync - run: | - cruft update --checkout ${{ steps.get-latest-tag.outputs.tag }} --skip-apply-ask --project-dir . - - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 - with: - commit-message: Automated template update from cookiecutter-scverse - branch: template-update - title: Automated template update from cookiecutter-scverse - body: | - A new version of the [scverse cookiecutter template](https://github.com/scverse/cookiecutter-scverse/releases) - got released. This PR adds all new changes to your repository and helps to stay in sync with - the latest best-practice template maintained by the scverse team. - - **If a merge conflict arised, a `.rej` file with the rejected patch is generated. You'll need to - manually merge these changes.** - - For more information about the template sync, please refer to the - [template documentation](https://cookiecutter-scverse-instance.readthedocs.io/en/latest/template_usage.html#automated-template-sync). diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dc7087c..def0b37 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,64 +1,64 @@ name: Test on: - push: - branches: [main] - pull_request: - branches: [main] + push: + branches: [main] + pull_request: + branches: [main] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - test: - runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash -e {0} # -e to fail on error + test: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -e {0} # -e to fail on error - strategy: - fail-fast: false - matrix: - python: ["3.9", "3.11"] - os: [ubuntu-latest] + strategy: + fail-fast: false + matrix: + python: ["3.9", "3.11"] + os: [ubuntu-latest] - env: - OS: ${{ matrix.os }} - PYTHON: ${{ matrix.python }} + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python }} - steps: - - uses: actions/checkout@v3 + steps: + - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - cache: "pip" - cache-dependency-path: "**/pyproject.toml" + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: "pip" + cache-dependency-path: "**/pyproject.toml" - - name: Cache datasets - uses: actions/cache@v3 - with: - path: ~/.cache/genomic-features - key: "datasets-${{ hashFiles('**/pyproject.toml') }}')}}" - # TODO: Figure out better cache invalidation strategy + - name: Cache datasets + uses: actions/cache@v3 + with: + path: ~/.cache/genomic-features + key: "datasets-${{ hashFiles('**/pyproject.toml') }}')}}" + # TODO: Figure out better cache invalidation strategy - - name: Install test dependencies - run: | - python -m pip install --upgrade pip wheel + - name: Install test dependencies + run: | + python -m pip install --upgrade pip wheel - - name: Install dependencies - run: | - pip install ".[dev,test]" + - name: Install dependencies + run: | + pip install ".[dev,test]" - - name: Test - env: - MPLBACKEND: agg - PLATFORM: ${{ matrix.os }} - DISPLAY: :42 - run: | - pytest -v --cov --color=yes + - name: Test + env: + MPLBACKEND: agg + PLATFORM: ${{ matrix.os }} + DISPLAY: :42 + run: | + pytest -v --cov --color=yes - - name: Upload coverage - uses: codecov/codecov-action@v3 + - name: Upload coverage + uses: codecov/codecov-action@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f6504a..86ab215 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,40 +1,38 @@ fail_fast: false default_language_version: - python: python3 + python: python3 default_stages: - - commit - - push + - commit + - push minimum_pre_commit_version: 2.16.0 repos: - - repo: https://github.com/psf/black - rev: "23.3.0" - hooks: - - id: black - - repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 - hooks: - - id: blacken-docs - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.262 - hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: detect-private-key - - id: check-ast - - id: end-of-file-fixer - - id: mixed-line-ending - args: [--fix=lf] - - id: trailing-whitespace - - id: check-case-conflict - - repo: local - hooks: - - id: forbid-to-commit - name: Don't commit rej files - entry: | - Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates. - Fix the merge conflicts manually and remove the .rej files. - language: fail - files: '.*\.rej$' + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.4 + hooks: + - id: ruff + types_or: [python, pyi, jupyter] + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: detect-private-key + - id: check-ast + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: trailing-whitespace + - id: check-case-conflict + # Check that there are no merge conflicts (could be generated by template sync) + - id: check-merge-conflict + args: [--assume-in-merge] + - repo: local + hooks: + - id: forbid-to-commit + name: Don't commit rej files + entry: | + Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates. + Fix the merge conflicts manually and remove the .rej files. + language: fail + files: '.*\.rej$' diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9e5d5fa..69897c3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,16 +1,16 @@ # https://docs.readthedocs.io/en/stable/config-file/v2.html version: 2 build: - os: ubuntu-20.04 - tools: - python: "3.10" + os: ubuntu-20.04 + tools: + python: "3.10" sphinx: - configuration: docs/conf.py - # disable this for more lenient docs builds - fail_on_warning: true + configuration: docs/conf.py + # disable this for more lenient docs builds + fail_on_warning: true python: - install: - - method: pip - path: . - extra_requirements: - - doc + install: + - method: pip + path: . + extra_requirements: + - doc diff --git a/docs/_static/css/custom.css b/docs/_static/css/custom.css new file mode 100644 index 0000000..b8c8d47 --- /dev/null +++ b/docs/_static/css/custom.css @@ -0,0 +1,4 @@ +/* Reduce the font size in data frames - See https://github.com/scverse/cookiecutter-scverse/issues/193 */ +div.cell_output table.dataframe { + font-size: 0.8em; +} diff --git a/docs/conf.py b/docs/conf.py index 198ffd8..0b296d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -110,12 +110,15 @@ # html_theme = "sphinx_book_theme" html_static_path = ["_static"] +html_css_files = ["css/custom.css"] + html_title = project_name html_theme_options = { "repository_url": repository_url, "use_repository_button": True, "path_to_docs": "docs/", + "navigation_with_keys": False, } pygments_style = "default" @@ -136,18 +139,3 @@ # Ibis uses mkdocs (r".*", r"ibis\..*"), ] - - -def setup(app): - """App setup hook.""" - app.add_config_value( - "recommonmark_config", - { - "auto_toc_tree_section": "Contents", - "enable_auto_toc_tree": True, - "enable_math": True, - "enable_inline_math": False, - "enable_eval_rst": True, - }, - True, - ) diff --git a/docs/contributing.md b/docs/contributing.md index eb45e7e..1105f12 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -1,6 +1,6 @@ # Contributing guide -Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this repo, too. +Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this project, too. This document will not reproduce the entire content from there. Instead, it aims at summarizing the most important information to get you started on contributing. @@ -19,9 +19,8 @@ pip install -e ".[dev,test,doc]" ## Code-style -This template uses [pre-commit][] to enforce consistent code-styles. On every commit, pre-commit checks will either -automatically fix issues with the code, or raise an error message. See [pre-commit checks](template_usage.md#pre-commit-checks) for -a full list of checks enabled for this repository. +This package uses [pre-commit][] to enforce consistent code-styles. +On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message. To enable pre-commit locally, simply run @@ -43,16 +42,16 @@ git pull --rebase to integrate the changes into yours. While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage. -Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [black][black-editors] +Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [ruff][ruff-editors] and [prettier][prettier-editors]. -[black-editors]: https://black.readthedocs.io/en/stable/integrations/editors.html +[ruff-editors]: https://docs.astral.sh/ruff/integrations/ [prettier-editors]: https://prettier.io/docs/en/editors.html ## Writing tests ```{note} -Remember to first install the package with `pip install '-e[dev,test]'` +Remember to first install the package with `pip install -e '.[dev,test]'` ``` This package uses the [pytest][] for automated testing. Please [write tests][scanpy-test-docs] for every function added @@ -65,7 +64,17 @@ command line by executing pytest ``` -in the root of the repository. Continuous integration will automatically run the tests on all pull requests. +in the root of the repository. + +### Continuous integration + +Continuous integration will automatically run the tests on all pull requests and test +against the minimum and maximum supported Python version. + +Additionally, there's a CI job that tests against pre-releases of all dependencies +(if there are any). The purpose of this check is to detect incompatibilities +of new package versions early on and gives you time to fix the issue or reach +out to the developers of the dependency before the package is released to a wider audience. [scanpy-test-docs]: https://scanpy.readthedocs.io/en/latest/dev/testing.html#writing-tests @@ -73,7 +82,7 @@ in the root of the repository. Continuous integration will automatically run the ### Updating the version number -Before making a release, you need to update the version number. Please adhere to [Semantic Versioning][semver], in brief +Before making a release, you need to update the version number in the `pyproject.toml` file. Please adhere to [Semantic Versioning][semver], in brief > Given a version number MAJOR.MINOR.PATCH, increment the: > @@ -83,56 +92,8 @@ Before making a release, you need to update the version number. Please adhere to > > Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format. -We use [bump2version][] to automatically update the version number in all places and automatically create a git tag. -Run one of the following commands in the root of the repository - -```bash -bump2version patch -bump2version minor -bump2version major -``` - -Once you are done, run - -``` -git push --tags -``` - -to publish the created tag on GitHub. - -[bump2version]: https://github.com/c4urself/bump2version - -### Building and publishing the package on PyPI - -Python packages are not distributed as source code, but as _distributions_. The most common distribution format is the so-called _wheel_. To build a _wheel_, run - -```bash -python -m build -``` - -This command creates a _source archive_ and a _wheel_, which are required for publishing your package to [PyPI][]. These files are created directly in the root of the repository. - -Before uploading them to [PyPI][] you can check that your _distribution_ is valid by running: - -```bash -twine check dist/* -``` - -and finally publishing it with: - -```bash -twine upload dist/* -``` - -Provide your username and password when requested and then go check out your package on [PyPI][]! - -For more information, follow the [Python packaging tutorial][]. - -It is possible to automate this with GitHub actions, see also [this feature request][pypi-feature-request] -in the cookiecutter-scverse template. - -[python packaging tutorial]: https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives -[pypi-feature-request]: https://github.com/scverse/cookiecutter-scverse/issues/88 +Once you are done, commit and push your changes and navigate to the "Releases" page of this project on GitHub. +Specify `vX.X.X` as a tag name and create a release. For more information, see [managing GitHub releases][]. This will automatically create a git tag and trigger a Github workflow that creates a release on PyPI. ## Writing documentation @@ -151,7 +112,7 @@ on how to write documentation. The documentation is set-up to render jupyter notebooks stored in the `docs/notebooks` directory using [myst-nb][]. Currently, only notebooks in `.ipynb` format are supported that will be included with both their input and output cells. -It is your reponsibility to update and re-run the notebook whenever necessary. +It is your responsibility to update and re-run the notebook whenever necessary. If you are interested in automatically running notebooks as part of the continuous integration, please check out [this feature request](https://github.com/scverse/cookiecutter-scverse/issues/40) in the `cookiecutter-scverse` @@ -196,3 +157,4 @@ open _build/html/index.html [numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html [sphinx autodoc typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints [pypi]: https://pypi.org/ +[managing GitHub releases]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository diff --git a/docs/index.md b/docs/index.md index 10582e4..2607a2e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,7 +9,6 @@ notebooks/basic_usage api.md changelog.md -template_usage.md contributing.md references.md ``` diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 954237b..0000000 --- a/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "" goto help - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/docs/notebooks/basic_usage.ipynb b/docs/notebooks/basic_usage.ipynb index 0a90d2f..ee5fb43 100644 --- a/docs/notebooks/basic_usage.ipynb +++ b/docs/notebooks/basic_usage.ipynb @@ -250,7 +250,7 @@ } ], "source": [ - "gf.ensembl.list_ensdb_annotations(species='Mmusculus')" + "gf.ensembl.list_ensdb_annotations(species=\"Mmusculus\")" ] }, { @@ -854,7 +854,8 @@ ], "source": [ "ensdb.genes(\n", - " filter=gf.filters.GeneBioTypeFilter(\"lncRNA\") & gf.filters.GeneRangesFilter(\"1:10000-20000\")\n", + " filter=gf.filters.GeneBioTypeFilter(\"lncRNA\")\n", + " & gf.filters.GeneRangesFilter(\"1:10000-20000\")\n", ")" ] }, @@ -1128,6 +1129,7 @@ "source": [ "import pandas as pd\n", "import scanpy as sc\n", + "\n", "pbmc = sc.datasets.pbmc3k()" ] }, @@ -1214,19 +1216,16 @@ "metadata": {}, "outputs": [], "source": [ - "pbmc.var = (\n", - " pd.merge(\n", - " (\n", - " pbmc.var\n", - " .reset_index()\n", - " .rename(columns={\"gene_ids\": \"gene_id\", \"index\": \"orig_gene_name\"})\n", - " ),\n", - " genes,\n", - " on=\"gene_id\",\n", - " how=\"left\",\n", - " )\n", - " .set_index(\"gene_id\")\n", - ")" + "pbmc.var = pd.merge(\n", + " (\n", + " pbmc.var.reset_index().rename(\n", + " columns={\"gene_ids\": \"gene_id\", \"index\": \"orig_gene_name\"}\n", + " )\n", + " ),\n", + " genes,\n", + " on=\"gene_id\",\n", + " how=\"left\",\n", + ").set_index(\"gene_id\")" ] }, { diff --git a/docs/template_usage.md b/docs/template_usage.md deleted file mode 100644 index 6c01997..0000000 --- a/docs/template_usage.md +++ /dev/null @@ -1,364 +0,0 @@ -# Using this template - -Welcome to the developer guidelines! This document is split into two parts: - -1. The [repository setup](#setting-up-the-repository). This section is relevant primarily for the repository maintainer and shows how to connect - continuous integration services and documents initial set-up of the repository. -2. The [contributor guide](contributing.md#contributing-guide). It contains information relevant to all developers who want to make a contribution. - -## Setting up the repository - -### First commit - -If you are reading this, you should have just completed the repository creation with : - -```bash -cruft create https://github.com/scverse/cookiecutter-scverse -``` - -and you should have - -``` -cd genomic-features -``` - -into the new project directory. Now that you have created a new repository locally, the first step is to push it to github. To do this, you'd have to create a **new repository** on github. -You can follow the instructions directly on [github quickstart guide][]. -Since `cruft` already populated the local repository of your project with all the necessary files, we suggest to _NOT_ initialize the repository with a `README.md` file or `.gitignore`, because you might encounter git conflicts on your first push. -If you are familiar with git and knows how to handle git conflicts, you can go ahead with your preferred choice. - -:::{note} -If you are looking at this document in the [cookiecutter-scverse-instance][] repository documentation, throughout this document the name of the project is `cookiecutter-scverse-instance`. Otherwise it should be replaced by your new project name: `genomic-features`. -::: - -Now that your new project repository has been created on github at `https://github.com/scverse/genomic-features` you can push your first commit to github. -To do this, simply follow the instructions on your github repository page or a more verbose walkthrough here: - -Assuming you are in `/your/path/to/genomic-features`. Add all files and commit. - -```bash -# stage all files of your new repo -git add --all -# commit -git commit -m "first commit" -``` - -You'll notice that the command `git commit` installed a bunch of packages and triggered their execution: those are pre-commit! To read more about what they are and what they do, you can go to the related section [Pre-commit checks](#pre-commit-checks) in this document. - -:::{note} -There is a chance that `git commit -m "first commit"` fails due to the `prettier` pre-commit formatting the file `.cruft.json`. No problem, you have just experienced what pre-commit checks do in action. Just go ahead and re-add the modified file and try to commit again: - -```bash - git add -u # update all tracked file - git commit -m "first commit" -``` - -::: - -Now that all the files of the newly created project have been committed, go ahead with the remaining steps: - -```bash -# update the `origin` of your local repo with the remote github link -git remote add origin https://github.com/scverse/genomic-features.git -# rename the default branch to main -git branch -M main -# push all your files to remote -git push -u origin main -``` - -Your project should be now available at `https://github.com/scverse/genomic-features`. While the repository at this point can be directly used, there are few remaining steps that needs to be done in order to achieve full functionality. - -### Coverage tests with _Codecov_ - -Coverage tells what fraction of the code is "covered" by unit tests, thereby encouraging contributors to -[write tests](contributing.md#writing-tests). -To enable coverage checks, head over to [codecov][] and sign in with your GitHub account. -You'll find more information in "getting started" section of the [codecov docs][]. - -In the `Actions` tab of your projects' github repository, you can see that the workflows are failing due to the **Upload coverage** step. The error message in the workflow should display something like: - -``` -... - Retrying 5/5 in 2s.. - {'detail': ErrorDetail(string='Could not find a repository, try using repo upload token', code='not_found')} -Error: 404 Client Error: Not Found for url: -... -``` - -While [codecov docs][] has a very extensive documentation on how to get started, _if_ you are using the default settings of this template we can assume that you are using [codecov][] in a github action workflow and hence you can make use of the [codecov bot][]. - -To set it up, simply go to the [codecov app][] page and follow the instructions to activate it for your repository. -Once the activation is completed, go back to the `Actions` tab and re-run the failing workflows. - -The workflows should now succeed and you will be able to find the code coverage at this link: `https://app.codecov.io/gh/scverse/genomic-features`. You might have to wait couple of minutes and the coverage of this repository should be ~60%. - -If your repository is private, you will have to specify an additional token in the repository secrets. In brief, you need to: - -1. Generate a Codecov Token by clicking _setup repo_ in the codecov dashboard. - - If you have already set up codecov in the repository by following the previous steps, you can directly go to the codecov repo webpage. -2. Go to _Settings_ and copy **only** the token `_______-____-...`. -3. Go to _Settings_ of your newly created repository on GitHub. -4. Go to _Security > Secrets > Actions_. -5. Create new repository secret with name `CODECOV_TOKEN` and paste the token generated by codecov. -6. Past these additional lines in `/.github/workflows.test.yaml` under the **Upload coverage** step: - ```bash - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - ``` -7. Go back to github `Actions` page an re-run previously failed jobs. - -### Documentation on _readthedocs_ - -We recommend using [readthedocs.org][] (RTD) to build and host the documentation for your project. -To enable readthedocs, head over to [their website][readthedocs.org] and sign in with your GitHub account. -On the RTD dashboard choose "Import a Project" and follow the instructions to add your repository. - -- Make sure to choose the correct name of the default branch. On GitHub, the name of the default branch should be `main` (it has - recently changed from `master` to `main`). -- We recommend to enable documentation builds for pull requests (PRs). This ensures that a PR doesn't introduce changes - that break the documentation. To do so, got to `Admin -> Advanced Settings`, check the - `Build pull requests for this projects` option, and click `Save`. For more information, please refer to - the [official RTD documentation](https://docs.readthedocs.io/en/stable/pull-requests.html). -- If you find the RTD builds are failing, you can disable the `fail_on_warning` option in `.readthedocs.yaml`. - -If your project is private, there are ways to enable docs rendering on [readthedocs.org][] but it is more cumbersome and requires a different subscription for read the docs. See a guide [here](https://docs.readthedocs.io/en/stable/guides/importing-private-repositories.html). - -### Pre-commit checks - -[Pre-commit][] checks are fast programs that -check code for errors, inconsistencies and code styles, before the code -is committed. - -This template uses a number of pre-commit checks. In this section we'll detail what is used, where they're defined, and how to modify these checks. - -#### Pre-commit CI - -We recommend setting up [pre-commit.ci][] to enforce consistency checks on every commit -and pull-request. - -To do so, head over to [pre-commit.ci][] and click "Sign In With GitHub". Follow -the instructions to enable pre-commit.ci for your account or your organization. You -may choose to enable the service for an entire organization or on a per-repository basis. - -Once authorized, pre-commit.ci should automatically be activated. - -#### Overview of pre-commit hooks used by the template - -The following pre-commit hooks are for code style and format: - -- [black](https://black.readthedocs.io/en/stable/): - standard code formatter in Python. -- [blacken-docs](https://github.com/asottile/blacken-docs): - black on Python code in docs. -- [prettier](https://prettier.io/docs/en/index.html): - standard code formatter for non-Python files (e.g. YAML). -- [ruff][] based checks: - - [isort](https://beta.ruff.rs/docs/rules/#isort-i) (rule category: `I`): - sort module imports into sections and types. - - [pydocstyle](https://beta.ruff.rs/docs/rules/#pydocstyle-d) (rule category: `D`): - pydocstyle extension of flake8. - - [flake8-tidy-imports](https://beta.ruff.rs/docs/rules/#flake8-tidy-imports-tid) (rule category: `TID`): - tidy module imports. - - [flake8-comprehensions](https://beta.ruff.rs/docs/rules/#flake8-comprehensions-c4) (rule category: `C4`): - write better list/set/dict comprehensions. - - [pyupgrade](https://beta.ruff.rs/docs/rules/#pyupgrade-up) (rule category: `UP`): - upgrade syntax for newer versions of the language. - -The following pre-commit hooks are for errors and inconsistencies: - -- [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks): generic pre-commit hooks for text files. - - **detect-private-key**: checks for the existence of private keys. - - **check-ast**: check whether files parse as valid python. - - **end-of-file-fixer**: check files end in a newline and only a newline. - - **mixed-line-ending**: checks mixed line ending. - - **trailing-whitespace**: trims trailing whitespace. - - **check-case-conflict**: check files that would conflict with case-insensitive file systems. - - **forbid-to-commit**: Make sure that `*.rej` files cannot be commited. - These files are created by the [automated template sync](#automated-template-sync) - if there's a merge conflict and need to be addressed manually. -- [ruff][] based checks: - - [pyflakes](https://beta.ruff.rs/docs/rules/#pyflakes-f) (rule category: `F`): - various checks for errors. - - [pycodestyle](https://beta.ruff.rs/docs/rules/#pycodestyle-e-w) (rule category: `E`, `W`): - various checks for errors. - - [flake8-bugbear](https://beta.ruff.rs/docs/rules/#flake8-bugbear-b) (rule category: `B`): - find possible bugs and design issues in program. - - [flake8-blind-except](https://beta.ruff.rs/docs/rules/#flake8-blind-except-ble) (rule category: `BLE`): - checks for blind, catch-all `except` statements. - - [Ruff-specific rules](https://beta.ruff.rs/docs/rules/#ruff-specific-rules-ruf) (rule category: `RUF`): - - `RUF100`: remove unneccesary `# noqa` comments () - -#### How to add or remove pre-commit checks - -The [pre-commit checks](#pre-commit-checks) check for both correctness and stylistic errors. -In some cases it might overshoot and you may have good reasons to ignore certain warnings. -This section shows you where these checks are defined, and how to enable/ disable them. - -##### pre-commit - -You can add or remove pre-commit checks by simply deleting relevant lines in the `.pre-commit-config.yaml` file under the repository root. -Some pre-commit checks have additional options that can be specified either in the `pyproject.toml` (for `ruff` and `black`) or tool-specific -config files, such as `.prettierrc.yml` for **prettier**. - -##### Ruff - -This template configures `ruff` through the `[tool.ruff]` entry in the `pyproject.toml`. -For further information `ruff` configuration, see [the docs](https://beta.ruff.rs/docs/configuration/). - -Ruff assigns code to the rules it checks (e.g. `E401`) and groups them under a rule category (e.g. `E`). -Rule categories are selectively enabled by including them under the `select` key: - -```toml -[tool.ruff] -... - -select = [ - "F", # Errors detected by Pyflakes - "E", # Error detected by Pycodestyle - "W", # Warning detected by Pycodestyle - "I", # isort - ... -] -``` - -The `ignore` entry is used to disable specific rules for the entire project. -Add the rule code(s) you want to ignore and don't forget to add a comment explaining why. -You can find a long list of checks that this template disables by default sitting there already. - -```toml -ignore = [ - ... - # __magic__ methods are are often self-explanatory, allow missing docstrings - "D105", - ... -] -``` - -Checks can be ignored per-file (or glob pattern) with `[tool.ruff.per-file-ignores]`. - -```toml -[tool.ruff.per-file-ignores] -"docs/*" = ["I"] -"tests/*" = ["D"] -"*/__init__.py" = ["F401"] -``` - -To ignore a specific rule on a per-case basis, you can add a `# noqa: [, , …]` comment to the offending line. -Specify the rule code(s) to ignore, with e.g. `# noqa: E731`. Check the [Ruff guide][] for reference. - -```{note} -The `RUF100` check will remove rule codes that are no longer necessary from `noqa` comments. -If you want to add a code that comes from a tool other than Ruff, -add it to Ruff’s [`external = [...]`](https://beta.ruff.rs/docs/settings/#external) setting to prevent `RUF100` from removing it. -``` - -[ruff]: https://beta.ruff.rs/docs/ -[ruff guide]: https://beta.ruff.rs/docs/configuration/#suppressing-errors - -### API design - -Scverse ecosystem packages should operate on [AnnData][] and/or [MuData][] data structures and typically use an API -as originally [introduced by scanpy][scanpy-api] with the following submodules: - -- `pp` for preprocessing -- `tl` for tools (that, compared to `pp` generate interpretable output, often associated with a corresponding plotting - function) -- `pl` for plotting functions - -You may add additional submodules as appropriate. While we encourage to follow a scanpy-like API for ecosystem packages, -there may also be good reasons to choose a different approach, e.g. using an object-oriented API. - -[scanpy-api]: https://scanpy.readthedocs.io/en/stable/usage-principles.html - -### Using VCS-based versioning - -By default, the template uses hard-coded version numbers that are set in `pyproject.toml` and [managed with -bump2version](contributing.md#publishing-a-release). If you prefer to have your project automatically infer version numbers from git -tags, it is straightforward to switch to vcs-based versioning using [hatch-vcs][]. - -In `pyproject.toml` add the following changes, and you are good to go! - -```diff ---- a/pyproject.toml -+++ b/pyproject.toml -@@ -1,11 +1,11 @@ - [build-system] - build-backend = "hatchling.build" --requires = ["hatchling"] -+requires = ["hatchling", "hatch-vcs"] - - - [project] - name = "genomic-features" --version = "0.3.1dev" -+dynamic = ["version"] - -@@ -60,6 +60,9 @@ -+[tool.hatch.version] -+source = "vcs" -+ - [tool.coverage.run] - source = ["genomic-features"] - omit = [ -``` - -Don't forget to update the [Making a release section](contributing.md#publishing-a-release) in this document accordingly, after you are done! - -[hatch-vcs]: https://pypi.org/project/hatch-vcs/ - -### Automated template sync - -Automated template sync is enabled by default. This means that every night, a GitHub action runs [cruft][] to check -if a new version of the `scverse-cookiecutter` template got released. If there are any new changes, a pull request -proposing these changes is created automatically. This helps keeping the repository up-to-date with the latest -coding standards. - -It may happen that a template sync results in a merge conflict. If this is the case a `*.ref` file with the -diff is created. You need to manually address these changes and remove the `.rej` file when you are done. -The pull request can only be merged after all `*.rej` files have been removed. - -:::{tip} -The following hints may be useful to work with the template sync: - -- GitHub automatically disables scheduled actions if there has been not activity to the repository for 60 days. - You can re-enable or manually trigger the sync by navigating to `Actions` -> `Sync Template` in your GitHub repository. -- If you want to ignore certain files from the template update, you can add them to the `[tool.cruft]` section in the - `pyproject.toml` file in the root of your repository. More details are described in the - [cruft documentation][cruft-update-project]. -- To disable the sync entirely, simply remove the file `.github/workflows/sync.yaml`. - -::: - -[cruft]: https://cruft.github.io/cruft/ -[cruft-update-project]: https://cruft.github.io/cruft/#updating-a-project - -## Moving forward - -You have reached the end of this document. Congratulations! You have successfully set up your project and are ready to start. -For everything else related to documentation, code style, testing and publishing your project ot pypi, please refer to the [contributing docs](contributing.md#contributing-guide). - - - -[scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html -[cookiecutter-scverse-instance]: https://cookiecutter-scverse-instance.readthedocs.io/en/latest/template_usage.html -[github quickstart guide]: https://docs.github.com/en/get-started/quickstart/create-a-repo?tool=webui -[codecov]: https://about.codecov.io/sign-up/ -[codecov docs]: https://docs.codecov.com/docs -[codecov bot]: https://docs.codecov.com/docs/team-bot -[codecov app]: https://github.com/apps/codecov -[pre-commit.ci]: https://pre-commit.ci/ -[readthedocs.org]: https://readthedocs.org/ -[myst-nb]: https://myst-nb.readthedocs.io/en/latest/ -[jupytext]: https://jupytext.readthedocs.io/en/latest/ -[pre-commit]: https://pre-commit.com/ -[anndata]: https://github.com/scverse/anndata -[mudata]: https://github.com/scverse/mudata -[pytest]: https://docs.pytest.org/ -[semver]: https://semver.org/ -[sphinx]: https://www.sphinx-doc.org/en/master/ -[myst]: https://myst-parser.readthedocs.io/en/latest/intro.html -[numpydoc-napoleon]: https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html -[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html -[sphinx autodoc typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints diff --git a/pyproject.toml b/pyproject.toml index 6d7314e..0b1f82c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,11 +45,12 @@ doc = [ "myst-nb", "sphinxcontrib-bibtex>=1.0.0", "sphinx-autodoc-typehints", + "sphinxext.opengraph", + "matplotlib", # Optional dep of sphinxext.opengraph # For notebooks "ipykernel", "ipython", "sphinx-copybutton", - "sphinxext.opengraph", ] test = [ "pytest", @@ -69,14 +70,15 @@ addopts = [ "--import-mode=importlib", # allow using test files with same name ] -[tool.black] -line-length = 88 -target-version = ["py39"] - [tool.ruff] src = ["src"] line-length = 88 -target-version = "py39" +extend-include = ["*.ipynb"] + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] select = [ "F", # Errors detected by Pyflakes "E", # Error detected by Pycodestyle @@ -91,7 +93,7 @@ select = [ "RUF100", # Report unused noqa directives ] ignore = [ - # line too long -> we accept long comment lines; black gets rid of long code lines + # line too long -> we accept long comment lines; formatter gets rid of long code lines "E501", # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient "E731", @@ -118,10 +120,10 @@ ignore = [ "D213", ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "numpy" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "docs/*" = ["I"] "tests/*" = ["D"] "*/__init__.py" = ["F401"] @@ -139,5 +141,5 @@ skip = [ "docs/changelog.md", "docs/references.bib", "docs/references.md", - "docs/notebooks/example.ipynb" + "docs/notebooks/example.ipynb", ] diff --git a/src/genomic_features/_core/filters.py b/src/genomic_features/_core/filters.py index 0c74429..72bbdae 100644 --- a/src/genomic_features/_core/filters.py +++ b/src/genomic_features/_core/filters.py @@ -252,7 +252,7 @@ class CanonicalTxFilter(AbstractFilterExpr): >>> ensdb.transcripts(filter=gf.filters.CanonicalTxFilter()) >>> ensdb.exons( ... cols=["tx_id", "exon_id", "seq_name", "exon_seq_start", "exon_seq_end"], - ... filter=gf.filters.CanonicalTxFilter() + ... filter=gf.filters.CanonicalTxFilter(), ... ) """ diff --git a/tests/test_list_ensdb_annotations.py b/tests/test_list_ensdb_annotations.py index 81f23e5..7f9d469 100644 --- a/tests/test_list_ensdb_annotations.py +++ b/tests/test_list_ensdb_annotations.py @@ -3,7 +3,15 @@ import genomic_features as gf -SPECIES = ['Scerevisiae', 'Mmusculus_nzohlltj', 'Ggallus', 'Hsapiens', 'Mmusculus', 'Celegans'] +SPECIES = [ + "Scerevisiae", + "Mmusculus_nzohlltj", + "Ggallus", + "Hsapiens", + "Mmusculus", + "Celegans", +] + def test_ensdb_versions(): species_versions = gf.ensembl.list_ensdb_annotations("Hsapiens") @@ -13,16 +21,19 @@ def test_ensdb_versions(): species_versions = gf.ensembl.list_ensdb_annotations("Rnorvegicus") assert isinstance(species_versions, pd.DataFrame) + def test_missing_species(): # test error is raised when species is not found with pytest.raises(ValueError): gf.ensembl.list_ensdb_annotations("Homo sapiens") + def test_unique_versions(): # Check that different mouse strains are not considered the same species species_versions = gf.ensembl.list_ensdb_annotations("Mmusculus") assert species_versions.Ensembl_version.is_unique + def test_all_species(): species_versions = gf.ensembl.list_ensdb_annotations() - assert pd.Series(SPECIES).isin(species_versions['Species']).all() \ No newline at end of file + assert pd.Series(SPECIES).isin(species_versions["Species"]).all()