-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
inheritance_diagram AttributeError: 'NoneType' object has no attribute 'groups' #4019
Comments
Hi guys, I have the same problem here and I propose a solution here. In the function try_import the parameter objname is unicode, so this solution I proposed is treating the consequence of passing a non-unicode parameter, in this case, None - NoneType. This error breaks the making process, so I am using this fix until get into the real cause. What do you think about this fix? Tks |
the error happens, for example, when there are modules, that can not be found, which should not break the making process. I would agree to your solution, and additionally an ERROR Message, that at least shouts the name of the module that can not be found, would be nice to have. |
Your suggestion, is a good one too, but particularly don't like to call two times the function, one for test and another for using it if passes. Both should be enough for now. I looked into the code and found that the error could be generated by the [docutils parser (https://github.com/dpizetta/sphinx/blob/master/sphinx/ext/inheritance_diagram.py#L332). The parser includes strings ":parts:" and "1" as classes into the list of classes.
This part is extracted from the module doc. Just one of my files get this problem, but in this file I have lots of imports (~20), so I couldn't find why this is generated. More details: The function try_import() is called from import_classes() that receives the list of classes from InheritanceGraph class. This one is created in InheritanceDiagram, that is reimplemented from Directive of docutils which parses files. Finally: I think that is not necessary throw an error message this moment if the problem that occurs in your code is the same, because saying just that some file has this problem (with "parts" and "1") may not help, returning None is enough to not break the making process. If anyone is getting the problem that it not finds some "real" module I agree to include the error message. Could you test if this problem is the same (getting names)? Any other suggestions? |
Sorry, in your text there is the name of the not found module, that already produces a error message:
, but it tries to handle that exception and then goes to another one:
So, if it was the case, just return None is suficient for the problem. |
yep, for me it really is, I'm happy :-) |
Is there anything I can do for this? |
Hi, I can submit my PR. The problem is that I don't figure out what is the real cause of the problem. So I can't create a test for it. I'm using this fix, and I didn't find any problem with it. For me, this is just a logic problem (return of match is None), and it still keeps warning about the not found module. May you can accept the PR. Any other ideas?
|
I noticed invalid modname causes an AttributeError.
@dpizetta could you make a PR please? |
Fix #4019: exception treatment for AttributeError stopping make process
Subject: Exception occurs on make latexpdf in try_import of sphinx/ext/inheritance_diagram.py
Problem
Most Propably a user Error
Procedure to reproduce the problem
Error logs / results
Expected results
No Exception even if object is None
Reproducible project / your project
not necessary
Environment info
The text was updated successfully, but these errors were encountered: