For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

PyCharm gives a warning on PandasData instance creation



  • Hi,

    This is not really a problem, but a question for education purposes.

    When I try to import data from a DataFrame, PyCharm, apparently, gets confused by absence of arguments of PandasData.__init__(), showing a warning about unexpected data;

    0_1548321457772_c9cb098d-299a-48ca-88a3-9a5655cf104e-image.png

    I found a way to silence it by the following hack (I also need custom column names):

    class PData(bt.feeds.PandasData):
        params = (
            ("open", "o"),
            ("high", "h"),
            ("low", "l"),
            ("close", "c"),
            ("volume", "vol"),
            ("openinterest", None),
        )
    
        def __init__(self, dataname):
            """ This whole function is a dirty hack to silence unexpected
            argument (`dataname`) warning on class instance creation
            Args:
                dataname (pd.DataFrame): OHLC DataFrame
            """
            self.p.dataname = dataname
            super().__init__()
    

    It's quite annoying. Is there a cleaner way to get rid of it?
    Also, could someone give me a hint on why is it designed this way and how inheritance here actually works? Some link to read more about advantages of this would be nice.


  • administrators

    @queeq said in PyCharm gives a warning on PandasData instance creation:

    It's quite annoying. Is there a cleaner way to get rid of it?

    Most of the shells hijacking the Python kernel and getting in the way are actually annoying (Jupyter, Spyder, PyCharm, feel free to name your favourite winner of the hijacker of the day)

    There is for sure a code for PyCharm which you can put in a comment line which disables warnings, same as with PyFlakes, for example.

    @queeq said in PyCharm gives a warning on PandasData instance creation:

    could someone give me a hint on why is it designed this way and how inheritance here actually works?

    Read Docs - Platform Concepts, the section named Parameters



  • Thanks. Found how to suppress it indeed. Reference for future generations: https://www.jetbrains.com/help/pycharm/suppressing-inspections.html

    In this case it'll look like this:

    # noinspection PyArgumentList
    data = PData(dataname=df)
    


});