PyCharm type hinting weirdness

0 votes

While working with PyCharm, I am getting the following error: 

Expected 'collections.Iterable', got 'range[int]' instead

This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations.

for _ in range(x):

This is how I have written the for loop. Is there any other solution?

Jul 22 in Python by ana1504.k
• 7,870 points
79 views

1 answer to this question.

0 votes

This looks like a bug in PyCharm. A range object is an iterable, and an Iterable. In 3.4.3:

>>> import collections
>>> x = 3
>>> isinstance(range(x), collections.Iterable)
True

Try reporting the issue to PyCharm people.

answered Jul 22 by SDeb
• 13,160 points

Related Questions In Python

0 votes
1 answer

Type checking in Python

Use the type() function with the variable ...READ MORE

answered May 8, 2018 in Python by Nietzsche's daemon
• 4,260 points
26 views
0 votes
1 answer

What are the differences between type() and isinstance()?

To summarize the contents of other (already ...READ MORE

answered Jun 4, 2018 in Python by ariaholic
• 7,340 points
43 views
0 votes
1 answer

What are the differences between type() and is instance()?

Normally, in Python, you want your code ...READ MORE

answered Aug 6, 2018 in Python by Priyaj
• 56,900 points
28 views
0 votes
1 answer

What's the canonical way to check for type in Python?

To check if o is an instance ...READ MORE

answered Aug 24, 2018 in Python by Priyaj
• 56,900 points
38 views
0 votes
1 answer
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 56,900 points
389 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 14, 2018 in Python by Priyaj
• 56,900 points
38 views
0 votes
1 answer

“stub” __objclass__ in a Python class how to implement it?

You want to avoid interfering with this ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 56,900 points
58 views
0 votes
1 answer

How to get base class type in Python?

Yes, There is an alternative. You can ...READ MORE

answered Feb 8 in Python by SDeb
• 13,160 points
21 views
0 votes
1 answer

python structured/recarray type conversion behaviour

You need to specify a string width, ...READ MORE

answered May 15 in Python by SDeb
• 13,160 points
18 views