Does pants have a way to infer optional and type c...
# general
r
Does pants have a way to infer optional and type checking dependencies for Python? I have a module with a class that has a few methods that utilize pandas but those methods are rarely used and I want to make that dependency optional so it's not being included everywhere this module is.
Here's my import code for reference:
Copy code
try:
    # Pandas is a bulky library, so including it should be optional
    import pandas as pd
except ImportError:
    logging.getLogger(__file__).warning("Pandas is not installed! Calling any pandas related function will result in an error!")
But pandas is still showing up as a dependency when I run
pants dependencies --transitive
Just realized the person above me is asking nearly the same question 🙃
b
You can stmap the import with
# pants: no-infer-dep
🙏 1