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

"Unresolved attribute reference 'parse' for class 'object'... " in Pycharm IDE. #126

Closed
sbonnick opened this issue Sep 23, 2015 · 10 comments
Assignees
Labels

Comments

@sbonnick
Copy link
Contributor

Error:
"Unresolved attribute reference 'parse' for class 'object'... " in Pycharm IDE.

Version:
parsedatetime-1.5

Code to reproduce:

    from time import mktime
    import parsedatetime
    from datetime import datetime

    cal = parsedatetime.Calendar()
    time_struct, parse_status = cal.parse("tomorrow")
    datetime.fromtimestamp(mktime(time_struct))

cal.parse -> cal is not being detects as class Calendar and instead as object, which of course has no definition parse. Not sure what exactly is causing this, but my guess would be due to Calendar() being embedded in the init.py file.

I do not see this issue while importing any other python modules.

@sbonnick sbonnick changed the title "Unresolved attribute referance 'parse' for class 'object'... " in Pycharm IDE. "Unresolved attribute reference 'parse' for class 'object'... " in Pycharm IDE. Sep 23, 2015
@bear
Copy link
Owner

bear commented Sep 23, 2015

what version of parsedatetime?

@sbonnick
Copy link
Contributor Author

1.5

@bear
Copy link
Owner

bear commented Sep 23, 2015

oh - silly me - you had that in your description - sorry!

let me reproduce it and see if it's solved by the v2 code or not - thanks

@bear bear added the bug label Sep 23, 2015
@bear bear self-assigned this Sep 23, 2015
@sbonnick
Copy link
Contributor Author

no problem ;)

@sbonnick
Copy link
Contributor Author

after thought: the IDE could be getting confused if it believes it is returning a plain object. I've seen similar behavior on functions that return a class object OR a dictionary. due to returning two different types, the IDE thinks it will always return the first return type. IE:

def test_def():
    dict_var = { "Key": "Value" }
    return dict_var or module.class()

IDE will always assume the above is returning a dictionary, so code-completion on the "class()" class will not be given.

I doubt this is the issue, but maybe a pointer to whats causing the issue

@sbonnick
Copy link
Contributor Author

looking at the code, I don't see why we could not just drop the "object" implementation:

class Calendar(object):

to

class Calendar:

@bear
Copy link
Owner

bear commented Sep 23, 2015

if that solves this problem and the tests work, then yea let's get a PR for that going

@sbonnick
Copy link
Contributor Author

PR created

bear added a commit that referenced this issue Sep 24, 2015
Issue #126 - removed inheritance from object and removed return value…
@philiptzou
Copy link
Collaborator

Well, I think there must be a better reason for why PyCharm raised this error than inheritance of object. This perhaps an upstream bug of PyCharm or most likely there's some misconfiguration. Anyway, install a PyCharm and reappear this issue should be the first step but not just drop the inheritance.

@philiptzou
Copy link
Collaborator

Well happy ending of this issue. See #128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants