Skip to content

Use of hypothesis type annotations forces downstream projects to install hypothesis #1215

@leifwar

Description

@leifwar

Describe the bug
A clear and concise description of what the bug is.

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the master branch of pandera.

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

In 1fc05de a type annotation SearchStrategy[pd.Series] was added to series_strategy
(pandera/strategies/pandas_strategies.py). This forces downstream projects to install
hypothesis as the place holder for SearchStrategy defined in the same file does not
contain definition of __getitem__.

import pandera as pa

Importing pandera in a downstream project where hypothesis is not available will give the following error

../pandera/pandera/__init__.py:5: in <module>
    from pandera.accessors import pandas_accessor
../pandera/pandera/accessors/pandas_accessor.py:7: in <module>
    from pandera.api.pandas.array import SeriesSchema
../pandera/pandera/api/pandas/array.py:10: in <module>
    from pandera import strategies as st
../pandera/pandera/strategies/__init__.py:3: in <module>
    from pandera.strategies.pandas_strategies import *
../pandera/pandera/strategies/pandas_strategies.py:830: in <module>
    ) -> SearchStrategy[pd.Series]:
E   TypeError: type 'SearchStrategy' is not subscriptable

If hypothesis is available this does not happen.

Expected behavior

It should be possible to use pandera without installing hypothesis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions