Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Instantiate Abstract Class ProductionSession #74

Closed
alexonab opened this issue Jul 22, 2023 · 6 comments
Closed

Unable to Instantiate Abstract Class ProductionSession #74

alexonab opened this issue Jul 22, 2023 · 6 comments

Comments

@alexonab
Copy link
Contributor

alexonab commented Jul 22, 2023

from tastytrade import ProductionSession

import os
from dotenv import load_dotenv

load_dotenv()

username = os.environ["TW_USERNAME"]
password = os.environ["TW_PASSWORD"]

session = ProductionSession(username, password)

$ python tw.py

Traceback (most recent call last):
File "/tmp/tw/tw.py", line 11, in
session = ProductionSession(username, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Can't instantiate abstract class ProductionSession with abstract methods base_url, headers, session_token, user

@Graeme22
Copy link
Contributor

Can you post your code?

@alexonab
Copy link
Contributor Author

@Graeme22 I have added the code above.

@Graeme22
Copy link
Contributor

Hmmm... What's your python version?

@alexonab
Copy link
Contributor Author

Hmmm... What's your python version?

$ python
Python 3.11.4 (main, Jun 7 2023, 10:13:09) [GCC 12.2.0] on linux

@Mytak
Copy link
Contributor

Mytak commented Jul 24, 2023

Reproduced with Python 3.10.6, Ubuntu 22.04.

Code(working before update to V6.0):

from tastytrade import ProductionSession

class TastyTradeSession():
    def __init__(self, user):
        # Get credentials
        self.user = user
        self.password = keyring.get_password('Tastytrade', self.user)
        return
    
    def get_session(self):          
        return ProductionSession(self.user, self.password)

External call

tastytrade_session = session_handler.TastyTradeSession(args.user)
session = tastytrade_session.get_session()

Result:

TypeError: Can't instantiate abstract class TastyTradeSession with abstract methods base_url, headers, session_token, user

Graeme22 added a commit that referenced this issue Jul 24, 2023
@Graeme22
Copy link
Contributor

That's an ugly mistake by me! Sorry about that.

Basically, I had the package installed as an editable package and was testing in a Jupyter notebook, which prevented me from running into this. Fixing it right now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants