Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2021-22 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menĂ¹ personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2021-22 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

VIDEOLEZIONI DEL CORSO DI FONDAMENTI DI PROGRAMMAZIONE AA20-21

PROGRAMMING COURSE VIDEOCONFERENCES AY20-21

import of typing forbidden

z
zoe_matrullo (2090 points)
4 8 12
in HW8 by (2.1k 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?
207 views
closed

5 Answers

Best answer
gabrimat (5630 points)
2 3 25
by (5.6k points)
selected by
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)
6 10 22
by (5.8k 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
by (2.5k 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
by (2.1k points)
yes I'm using Spyder
rokshana03 (7140 points)
1 3 27
by (7.1k 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 (173640 points)
516 941 1795
by (174k points)
edited by
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
by (2.1k points)
the code is not finished but I uploaded it. In any case thanks.
andrea.sterbini (173640 points)
516 941 1795
by (174k 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.