Skip to content

Commit

Permalink
Some ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 20, 2025
1 parent a97db54 commit 4270ce8
Show file tree
Hide file tree
Showing 120 changed files with 358 additions and 530 deletions.
9 changes: 5 additions & 4 deletions notebooks/Bioregistry Taxonomy Curation via Wikidata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
"source": [
"# Get wikidata taxonomy properties\n",
"\n",
"import bioregistry\n",
"import bioregistry.version\n",
"import requests\n",
"import pandas as pd\n",
"from bioregistry.utils import norm, query_wikidata\n",
"import requests\n",
"from bs4 import BeautifulSoup\n",
"\n",
"import bioregistry\n",
"import bioregistry.version\n",
"from bioregistry.utils import query_wikidata\n",
"\n",
"pd.set_option(\"display.max_rows\", None)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@
}
],
"source": [
"import bioregistry.pandas as brpd\n",
"import pandas as pd\n",
"\n",
"import bioregistry.pandas as brpd\n",
"\n",
"# Focus on these columns when displaying the data\n",
"columns = [0, 1, 4, 5, 7, 12]\n",
"\n",
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Extract registry information."""

from .collection_api import get_collection, get_context # noqa:F401
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Command line interface for the bioregistry."""

from .cli import main # type:ignore
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

"""Analyses build on the Bioregistry."""
2 changes: 0 additions & 2 deletions src/bioregistry/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

"""Web application for the Bioregistry."""
5 changes: 2 additions & 3 deletions src/bioregistry/app/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-

"""FastAPI blueprint and routes."""

from __future__ import annotations

from typing import Any, List, Mapping, Optional, Set
from collections.abc import Mapping
from typing import Any, List, Optional, Set

import yaml
from curies import Reference
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/app/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Web command for running the app."""

from pathlib import Path
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/app/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*

"""Large data chunks for the web app."""

from bioregistry import version
Expand Down
3 changes: 2 additions & 1 deletion src/bioregistry/app/impl.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""App builder interface."""

import json
from collections.abc import Mapping
from pathlib import Path
from textwrap import dedent
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union
from typing import TYPE_CHECKING, Any, Optional, Union

from a2wsgi import WSGIMiddleware
from curies.mapping_service import MappingServiceGraph, MappingServiceSPARQLProcessor
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/app/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Test the resolution API."""

import sys
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/app/ui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""User blueprint for the bioregistry web application."""

from __future__ import annotations
Expand Down
13 changes: 6 additions & 7 deletions src/bioregistry/app/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-

"""Utility functions for the Bioregistry :mod:`flask` app."""

import json
from collections.abc import Mapping, Sequence
from functools import partial
from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple

import yaml
from flask import (
Expand Down Expand Up @@ -87,22 +86,22 @@ def _autocomplete(manager_: Manager, q: str, url_prefix: Optional[str] = None) -
Before completion is of prefix:
>>> from bioregistry import manager
>>> _autocomplete(manager, 'cheb')
>>> _autocomplete(manager, "cheb")
{'query': 'cheb', 'results': [('chebi', ''), ('chebi', 'chebiid'), ('goche', 'gochebi')], 'success': True, 'reason': 'searched prefix', 'url': None}
If only prefix is complete:
>>> _autocomplete(manager, 'chebi')
>>> _autocomplete(manager, "chebi")
{'query': 'chebi', 'results': [('chebi', ''), ('chebi', 'chebiid'), ('goche', 'gochebi')], 'success': True, 'reason': 'matched prefix', 'url': '/chebi'}
Not matching the pattern:
>>> _autocomplete(manager, 'chebi:NOPE')
>>> _autocomplete(manager, "chebi:NOPE")
{'query': 'chebi:NOPE', 'prefix': 'chebi', 'pattern': '^\\d+$', 'identifier': 'NOPE', 'success': False, 'reason': 'failed validation', 'url': None}
Matching the pattern:
>>> _autocomplete(manager, 'chebi:1234')
>>> _autocomplete(manager, "chebi:1234")
{'query': 'chebi:1234', 'prefix': 'chebi', 'pattern': '^\\d+$', 'identifier': '1234', 'success': True, 'reason': 'passed validation', 'url': '/chebi:1234'}
""" # noqa: E501
if url_prefix is None:
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/app/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Web application for the Bioregistry."""

from bioregistry.app.impl import get_app
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/benchmarks/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Run the benchmarks CLI."""

from .cli import main
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/benchmarks/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Run all benchmarks."""

import click
Expand Down
3 changes: 2 additions & 1 deletion src/bioregistry/benchmarks/curie_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import itertools as itt
import random
import time
from collections.abc import Iterable
from statistics import mean
from typing import Iterable, Tuple
from typing import Tuple

import click
import matplotlib.pyplot as plt
Expand Down
3 changes: 2 additions & 1 deletion src/bioregistry/benchmarks/curie_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import random
import time
from typing import Iterable, Tuple
from collections.abc import Iterable
from typing import Tuple

import click
import matplotlib.pyplot as plt
Expand Down
3 changes: 2 additions & 1 deletion src/bioregistry/benchmarks/uri_parsing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""A benchmark for Bioregistry's URI parser."""

import time
from collections.abc import Iterable
from statistics import mean
from typing import Iterable, Tuple
from typing import Tuple

import click
import matplotlib.pyplot as plt
Expand Down
5 changes: 2 additions & 3 deletions src/bioregistry/bibliometrics.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-

"""Utilities for publications."""

import typing
from collections import Counter
from typing import TYPE_CHECKING, Iterable, List
from collections.abc import Iterable
from typing import TYPE_CHECKING, List

from .resource_manager import manager
from .schema.struct import Publication, deduplicate_publications
Expand Down
4 changes: 1 addition & 3 deletions src/bioregistry/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Command line interface for the bioregistry."""

import sys
Expand Down Expand Up @@ -87,7 +85,7 @@ def align(
secho(f"Aligning {aligner_cls.key}")
try:
aligner_cls.align(force_download=not no_force)
except (IOError, OLSBroken) as e:
except (OSError, OLSBroken) as e:
secho(f"Failed to align {aligner_cls.key}: {e}", fg="red")

if pre_digests != get_hexdigests():
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/collection_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""API for collections."""

from typing import Optional
Expand Down
9 changes: 5 additions & 4 deletions src/bioregistry/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _get_has_present(func: Callable[[str], X | None]) -> Counter[X]:


def _save(
fig: "matplotlib.figure.Figure",
fig: matplotlib.figure.Figure,
name: str,
*,
svg: bool = True,
Expand Down Expand Up @@ -733,8 +733,7 @@ def plot_xrefs(registry_infos, watermark: bool) -> FigAxPair:
ax.text(
x1,
h + 1,
f"No identifier resources are\navailable in more than\n"
f"{max_mapped} external registries",
f"No identifier resources are\navailable in more than\n{max_mapped} external registries",
horizontalalignment="center",
verticalalignment="bottom",
fontdict=dict(fontsize=12),
Expand Down Expand Up @@ -766,7 +765,9 @@ def _get_licenses_mapped_counter(threshold: int = 30) -> List[str]:
(
"None"
if license_ is None
else license_ if licenses_counter[license_] > threshold else "Other"
else license_
if licenses_counter[license_] > threshold
else "Other"
)
for license_ in licenses
]
Expand Down
10 changes: 4 additions & 6 deletions src/bioregistry/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Constants and utilities for registries."""

import importlib.metadata
Expand All @@ -11,13 +9,13 @@
import pystow

__all__ = [
"HERE",
"DATA_DIRECTORY",
"BIOREGISTRY_MODULE",
"BIOREGISTRY_PATH",
"METAREGISTRY_PATH",
"COLLECTIONS_PATH",
"DATA_DIRECTORY",
"HERE",
"METAREGISTRY_PATH",
"MISMATCH_PATH",
"BIOREGISTRY_MODULE",
"RAW_DIRECTORY",
]

Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/curation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

"""Curation tools."""
2 changes: 0 additions & 2 deletions src/bioregistry/curation/add_co_providers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Add providers for Crop Ontology entries."""

import click
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/curation/add_descriptions_from_gs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Add descriptions from a google curation sheet."""

import click
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/curation/add_examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Script for adding examples automatically."""

import random
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/curation/add_examples_from_javert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Script for adding examples automatically."""

import gzip
Expand Down
4 changes: 1 addition & 3 deletions src/bioregistry/curation/add_examples_from_ols.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-

"""Add examples from OLS."""

import random
from typing import Mapping
from collections.abc import Mapping

import requests
from tqdm import tqdm
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/curation/add_ontology_regexes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Assert regular expression patterns for common identifier styles."""

import re
Expand Down
3 changes: 2 additions & 1 deletion src/bioregistry/curation/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import sys
from collections import defaultdict
from typing import Any, DefaultDict, Dict, Mapping, Optional
from collections.abc import Mapping
from typing import Any, DefaultDict, Dict, Optional

import click
import pandas as pd
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/curation/deprecation_diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Show discrepancies between Bioregistry and OBO Foundry deprecation status."""

import click
Expand Down
2 changes: 1 addition & 1 deletion src/bioregistry/curation/import_pc_semiautomatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main():
def _works(url: str) -> bool:
try:
homepage_res = requests.head(url, timeout=3, allow_redirects=True)
except IOError:
except OSError:
return False
else:
return homepage_res.status_code == 200
Expand Down
2 changes: 1 addition & 1 deletion src/bioregistry/curation/literature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import enum

__all__ = [
"CurationRelevance",
"COLUMNS",
"CurationRelevance",
]

COLUMNS = [
Expand Down
3 changes: 1 addition & 2 deletions src/bioregistry/curation/make_description_curation_sheet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

"""Make a curation sheet for the bioregistry."""

import click
import pandas as pd

Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

"""Data in the bioregistry."""
2 changes: 0 additions & 2 deletions src/bioregistry/export/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

"""Exports for the Bioregistry."""
2 changes: 0 additions & 2 deletions src/bioregistry/export/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Export the Bioregistry."""

from .cli import export
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/export/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Export the Bioregistry."""

import click
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/export/prefix_maps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Export extended prefix maps (EPMs), JSON-LD contexts, and SHACL RDF documents.
.. seealso:: https://github.com/biopragmatics/bioregistry/pull/972
Expand Down
2 changes: 0 additions & 2 deletions src/bioregistry/export/rdf_export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Export the Bioregistry to RDF."""

import logging
Expand Down
Loading

0 comments on commit 4270ce8

Please sign in to comment.