import of typing forbidden

z
zoe_matrullo (2090 points)
4 8 12
asked Dec 15, 2021 in HW8 by zoe_matrullo (2,090 points)
Hi everyone!

when I test my homework I get this error

testlib.ForbiddenError: The import of 'typing' is forbidden

although I didn't import that module. Can anyone explain why this happens and what should I do?
194 views

5 Answers

Best answer
gabrimat (5630 points)
2 2 25
answered Dec 16, 2021 by gabrimat (5,630 points)
selected Dec 17, 2021 by zoe_matrullo
Some ides give you advices on what to import and when you press enter on the hint (probably without even noticing it) they automatically import the library. Happened to me a few times. Look for all the program sheet and try to search something like 'from typing import....' or 'import typing' and delete that. Let me know if you can find something, search above and below the homework assignment, the big commented text.
Simone Russolillo (5790 points)
5 10 22
answered Dec 15, 2021 by Simone Russolillo (5,790 points)
I've never seen this, but maybe it is a module imported from a built in function or something.

Check which line raises this error while in debugger mode. Maybe you can solve the problem.
gabriel.bustamante (2540 points)
3 5 20
answered Dec 15, 2021 by gabriel.bustamante (2,540 points)
https://docs.python.org/3/library/typing.html

It seems to be a module for hints, maybe your IDE automatically imports it. Are you using Spyder?
z
zoe_matrullo (2090 points)
4 8 12
commented Dec 15, 2021 by zoe_matrullo (2,090 points)
yes I'm using Spyder
rokshana03 (7140 points)
1 2 26
answered Dec 15, 2021 by rokshana03 (7,140 points)

I'm not sure if this is even possible or I'm saying something stupid but maybe you named something inside your code that, when you test your code, recognizes it as some method of that module?

This is the whole typing module with all its methods, you could check it. Otherwise, as Simone said, debugging is the only thing that can help you out in figuring where the mistake lays

andrea.sterbini (172680 points)
511 927 1776
answered Dec 16, 2021 by andrea.sterbini (172,680 points)
edited Dec 16, 2021 by andrea.sterbini
If you upload it I could have a look.

Anyway, you could deactivate all checks and timeout by setting DEBUG=True in test_01.py
z
zoe_matrullo (2090 points)
4 8 12
commented Dec 16, 2021 by zoe_matrullo (2,090 points)
the code is not finished but I uploaded it. In any case thanks.
andrea.sterbini (172680 points)
511 927 1776
commented Dec 16, 2021 by andrea.sterbini (172,680 points)
I am not getting on the VM the 'typing' import error but only the usual terminalwriter one.

I have corrected the tests to avoid spitting out the terminalwriter error. Please re-upload your code to get the true error.