biopragmatics / bioregistry

📮 An integrative registry of biological databases, ontologies, and nomenclatures.
https://bioregistry.io
MIT License
112 stars 49 forks source link

Specify __all__ to determine which functions should be explicitly exported #797

Open dhimmel opened 1 year ago

dhimmel commented 1 year ago

I encountered the following mypy error when type checking a module that does import bioregistry:

nxontology_data/utils.py:77: error: "Module bioregistry" does not explicitly
export attribute "normalize_parsed_curie"  [attr-defined]
        xref_prefix, xref_accession = bioregistry.normalize_parsed_curie(
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think the solution is for src/bioregistry/__init__.py to define __all__ as a list of strings that the package wants to make available at the top-level.

This occurs with mypy --strict, but probably not without strict when --no-implicit-reexport is not active.

dhimmel commented 1 year ago

Related: was happy to be able to enable type checking of bioregistry and bioversions in https://github.com/related-sciences/nxontology-data/commit/2bad0d61670e569dbe2f35376ea15361a9a594ca and https://github.com/related-sciences/nxontology-data/commit/ec3f47957c68d61235785c4fed607090175bd248!