Closed zhangda82 closed 6 years ago
Thanks for the report,
It should be fixed as soon as #1496 is merged. Please re-open if it is not the case.
fix in #1496 did not solve the issue of "'NoneType' object has no attribute 'name'". A quick fix as below worked, although I did not check if it ultimately fits in the context of this function.
elif definition.type in ['instance'] and (assignment is not None) and hasattr(assignment, "name"):
I guess there is a more fundamental error that cannot be fixed by simply adding more conditions as I suggested before:
elif definition.type in ['instance'] and (assignment is not None) and hasattr(assignment, "name"):
The problem is that elpy will keep complaining that None object does not have attribute "name".
Summary
Thank you for reporting to Elpy !
Here is a template to help you do it so your issue can be fixed as soon as possible. Please replace this paragraph with a summary of your issue and fill the next sections.
Steps to reproduce
My configuration
OS: Windows 10, Emacs 26.1
Result of
(elpy-config)
Error Message
'NoneType' object has no attribute 'name'
Configuration
Virtualenv........: None RPC Python........: 3.6.1 (c:/Anaconda3/pythonw.exe) Interactive Python: ipython (c:/Anaconda3/Scripts/ipython.exe) Emacs.............: 26.1 Elpy..............: 1.26.0 Jedi..............: 0.12.1 (0.13.1 available) Rope..............: 0.9.4-1 Autopep8..........: 1.3.5 (1.4.3 available) Yapf..............: 0.20.0 (0.24.0 available) Black.............: Not found (18.9b0 available) Syntax checker....: flake8.exe (c:/Anaconda3/Scripts/flake8.exe)
Traceback
Traceback (most recent call last): File "c:\home\zhangda.emacs.d\elpa\elpy-20181103.1105\elpy\rpc.py", line 100, in handle_request result = method(params) File "c:\home\zhangda.emacs.d\elpa\elpy-20181103.1105\elpy\server.py", line 79, in rpc_get_oneline_docstring get_source(source), offset) File "c:\home\zhangda.emacs.d\elpa\elpy-20181103.1105\elpy\server.py", line 44, in _call_backend return meth(args, **kwargs) File "c:\home\zhangda.emacs.d\elpa\elpy-20181103.1105\elpy\jedibackend.py", line 183, in rpc_get_oneline_docstring raw_name = assignment.name AttributeError: 'NoneType' object has no attribute 'name'
Elpy configuration in my init.el
(setq elpy-rpc-error-timeout 600000000) (setq elpy-rpc-timeout 5) (setq elpy-disable-backend-error-display t)
(defun my-elpy-mode-hook () (highlight-indentation-mode -1) (indent-guide-mode 1) (auto-complete-mode -1) (define-key elpy-mode-map "\C-m" 'newline-and-indent) (define-key elpy-mode-map "\C-j" 'electric-indent-just-newline) ;; I don't like elpy-nav-backward-indent and elpy-nav-foreward-indent taking my windmove key bindings (define-key elpy-mode-map (kbd "") 'windmove-left)
(define-key elpy-mode-map (kbd "") 'windmove-right)
(define-key elpy-mode-map (kbd "") 'windmove-up)
(define-key elpy-mode-map (kbd "") 'windmove-down)
(define-key elpy-mode-map (kbd "<C-.n>") 'elpy-goto-definition-other-window)
)
(add-hook 'elpy-mode-hook 'my-elpy-mode-hook)
(when (require 'elpy nil t) (elpy-enable))