Getting TypeError: argument: 'self' missing, while working with poetry and CLI

Viewed 43
  1. I am using poetry and sys.argv.
  2. I wrote the code in a OOP manner.
  3. While I am running code from CLI, I am getting an error as shown below.

Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: main() missing 1 required positional argument: 'self'

  1. I am taking argument from CLI and passing it to my script as mentioned below.
list_of_ticker = sys.argv[1].split(',')
print(list_of_ticker)

foo = CalculateEtfsYahoo(list_of_ticker)
foo.main()

FYI,

  1. The code is working, only after expected output I am getting above mentioned error.

  2. Also, I have added the module.pakage:class.function in pyproject.toml as shown below. [tool.poetry.scripts] findata = "investment.ParseFinData:CalculateEtfsYahoo.main"

  3. When I am replacing above point 2 with "module.package:class"

    [tool.poetry.scripts] findata = "investment.ParseFinData:CalculateEtfsYahoo"

And giving CLI command like this: poetry run findata.main <argument> then, I am getting error as Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: CalculateEtfsYahoo() missing 1 required positional argument: 'list_of_ticker'

I do not know how to get rid of this error.

1 Answers

if everyrthing is working and you just want to get rid of the error you could use

import warnings
warnings.filterwarnings("ignore", category=TypeError) #I'm not sure this is the correct category but change it if needed.
Related