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

110-easy-class-variable discussion #9

Open
J0 opened this issue May 24, 2021 · 1 comment
Open

110-easy-class-variable discussion #9

J0 opened this issue May 24, 2021 · 1 comment

Comments

@J0
Copy link

J0 commented May 24, 2021

For task 110 I had to rename the last variable from user to new_user as I'd previously received an error stating that we can't assign a type to a variable which already has a type. Would just like to check if there's an alternative solution which doesn't involve renaming the variable.

Here's the relevant line: https://github.com/J0/python-typing-koans/blob/main/koans/py/110-easy-class-variable.py#L66

@J0 J0 changed the title 110-easy-class-variable Solution 110-easy-class-variable discussion May 24, 2021
@kracekumar
Copy link
Owner

kracekumar commented May 24, 2021

I guess the indentation is causing the issue(in the original file). The mypy is in strict mode which uses user as variable User and the line new_user: Optional[User] = User.get_user(name="Guido") use variable as Optional[User]. This causes the mypy to raise error.

There is no issue with the your code, can you align the code like this and try?

def main() -> None:
 . ..

# Same level as main
user: Optional[User] = User.get_user(name="Guido")

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

2 participants