Skip to content

Utility to check for required imports and raise importerror #411

Open
@SultanOrazbayev

Description

@SultanOrazbayev

Based on this comment #391 (comment)

There is a repeated pattern of checking for function-specific imports and providing a helpful error message on failure to import, e.g.:

try:
import sparse
except ImportError: # pragma: no cover (import)
raise ImportError("sparse is required to import from pydata sparse") from None
if not isinstance(s, sparse.SparseArray):
raise TypeError(
"from_pydata_sparse only accepts objects from the `sparse` library; "
"see https://sparse.pydata.org"
)

This issue is to study the feasibility and value-added of extracting this logic into a separate utility function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    hygieneImprove code quality and reduce maintenance overhead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy