Skip to content

Regarding auto-import feature and datetime #540

Answered by smheidrich
dpetka2001 asked this question in Q&A
Discussion options

You must be logged in to vote

Explanation

This is a limitation of Rope: By default, it uses static analysis of Python source code to find out which names are available for import, but this can't work for C extension modules which don't have any Python source code.

Python's datetime module imports its actual contents from a C extension module named _datetime, so Rope can't find out about them using this default approach.

How to fix

Rope can be configured to introspect specific extension modules by actually executing them using the extension_modules option.

So to fix this, you can either add this to your project's .ropeproject/config.py file:

def set_prefs(prefs):
  prefs["extension_modules"] = ["_datetime"]

or this to …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@dpetka2001
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by dpetka2001
Comment options

You must be logged in to vote
1 reply
@dpetka2001
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants