- I am using poetry and sys.argv.
- I wrote the code in a OOP manner.
- 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'
- 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,
The code is working, only after expected output I am getting above mentioned error.
Also, I have added the module.pakage:class.function in pyproject.toml as shown below.
[tool.poetry.scripts] findata = "investment.ParseFinData:CalculateEtfsYahoo.main"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.