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

SublimeLinter: #4 pylint <untitled 42> ERROR #62

Closed
christianrickert opened this issue Jul 27, 2020 · 8 comments
Closed

SublimeLinter: #4 pylint <untitled 42> ERROR #62

christianrickert opened this issue Jul 27, 2020 · 8 comments

Comments

@christianrickert
Copy link

christianrickert commented Jul 27, 2020

Hello,

I have issues with using SublimeLinter-pylint, the linting is not working.
Unfortunately, I get an error message.

Steps to reproduce: I've installed all required software and packages
then opened a new document, changed the syntax to Python and
typed "print". Then this error was visible in the Sublime Text terminal:

// Output: SublimeLinter messages

SublimeLinter: #4 pylint <untitled 42> ERROR:
=============================================

Traceback (most recent call last):
  File "c:\python\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\python\Scripts\pylint.EXE\__main__.py", line 7, in <module>
  File "c:\python\lib\site-packages\pylint\__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "c:\python\lib\site-packages\pylint\lint\run.py", line 344, in __init__
    linter.check(args)
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 870, in check
    self._check_files(
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 903, in _check_files
    for name, filepath, modname in file_descrs:
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 960, in _iterate_file_descrs
    for descr in self._expand_files(files_or_modules):
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 977, in _expand_files
    self.add_message(key, args=message)
  File "c:\python\lib\site-packages\pylint\message\message_handler_mix_in.py", line 236, in add_message
    self.add_one_message(
  File "c:\python\lib\site-packages\pylint\message\message_handler_mix_in.py", line 290, in add_one_message
    self.stats["by_module"][self.current_name][msg_cat] += 1
KeyError: None
// Output SublimeLinter

<untitled 42>:
  No lint results. Running annotations.

Versions:

  • OS: Microsoft Windows [Version 10.0.18363.959]
  • Sublime Text 3: 3.2.2, build 3211
  • Package Control: 3.3.0
  • SublimeLinter: 4.15.0 / 1.8.0
  • SublimeLinter-pylint: 1.5.3
  • Python: 3.8.4 (tags/v3.8.4:dfa645a, Jul 13 2020, 16:46:45) [MSC v.1924 64 bit (AMD64)] on win32

Python and Pylint are accessible via PATH variable system-wide:

C:\Users\Christian Rickert>python --version
Python 3.8.4
C:\Users\Christian Rickert>pylint --version
pylint 2.5.3
astroid 2.4.2
Python 3.8.4 (tags/v3.8.4:dfa645a, Jul 13 2020, 16:46:45) [MSC v.1924 64 bit (AMD64)]

Sublime Text 3 console output is:

DPI mode: per-monitor v2
startup, version: 3211 windows x64 channel: stable
executable: /C/Program Files/Sublime Text 3/sublime_text.exe
working dir: /C/Program Files/Sublime Text 3
packages path: /C/Users/Christian Rickert/AppData/Roaming/Sublime Text 3/Packages
state path: /C/Users/Christian Rickert/AppData/Roaming/Sublime Text 3/Local
zip path: /C/Program Files/Sublime Text 3/Packages
zip path: /C/Users/Christian Rickert/AppData/Roaming/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.135543
font face "Roboto Mono" is not monospace, disabling bold and italic to prevent text reflow
first paint time: 0.211543
startup time: 0.228543
[git: tracking working dir]  // removed
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.detect_indentation
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.55-jsonschema
reloading plugin Gist.gist_05_import
reloading plugin Gist.gist_20_exceptions
reloading plugin Gist.gist_40_request
reloading plugin Gist.gist_60_helpers
reloading plugin Gist.gist_80
reloading plugin Gist.gitio
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SublimeLinter-annotations.linter
reloading plugin SublimeLinter-gcc.linter
reloading plugin SublimeLinter-pylint.linter
reloading plugin SublimeLinter.__init__
reloading plugin SublimeLinter.active_linters_view
reloading plugin SublimeLinter.busy_indicator_view
reloading plugin SublimeLinter.goto_commands
reloading plugin SublimeLinter.highlight_view
reloading plugin SublimeLinter.log_handler
reloading plugin SublimeLinter.message_view
reloading plugin SublimeLinter.panel_view
reloading plugin SublimeLinter.status_bar_view
reloading plugin SublimeLinter.sublime_linter
plugins loaded
Package Control: Skipping automatic upgrade, last run at 2020-07-26 18:29:22, next run at 2020-07-26 19:29:22 or after
SublimeLinter: ERROR: Traceback (most recent call last):
  File "c:\python\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\python\Scripts\pylint.EXE\__main__.py", line 7, in <module>
  File "c:\python\lib\site-packages\pylint\__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "c:\python\lib\site-packages\pylint\lint\run.py", line 344, in __init__
    linter.check(args)
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 870, in check
    self._check_files(
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 903, in _check_files
    for name, filepath, modname in file_descrs:
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 960, in _iterate_file_descrs
    for descr in self._expand_files(files_or_modules):
  File "c:\python\lib\site-packages\pylint\lint\pylinter.py", line 977, in _expand_files
    self.add_message(key, args=message)
  File "c:\python\lib\site-packages\pylint\message\message_handler_mix_in.py", line 236, in add_message
    self.add_one_message(
  File "c:\python\lib\site-packages\pylint\message\message_handler_mix_in.py", line 290, in add_one_message
    self.stats["by_module"][self.current_name][msg_cat] += 1
KeyError: None

Is there anything I can try to troubleshoot?

Chris

@kaste
Copy link
Contributor

kaste commented Jul 27, 2020

Hi! That's a hard crash of pylint itself. Check if you're running the newest version maybe. (In the traceback you see some paths. Are these correct, t.i. are you running the latest python just on c:/python? Or have you multiple pythons installed and we're picking an old one?)

@christianrickert
Copy link
Author

Hi @kaste

Python and pylint are the latest (stable) versions. I've removed other version from the system prior to testing.
I've played around a bit more and found that the error is triggered, when the file hasn't been saved to disk yet.

If I save the file first, before changing the syntax to Python (either automatically with providing a file extension
during saving or manually with the Sublime Text command menu), pylinter is not crashing:

DPI mode: per-monitor v2
startup, version: 3211 windows x64 channel: stable
executable: /C/Program Files/Sublime Text 3/sublime_text.exe
working dir: /C/Program Files/Sublime Text 3
packages path: /C/Users/Christian Rickert/AppData/Roaming/Sublime Text 3/Packages
state path: /C/Users/Christian Rickert/AppData/Roaming/Sublime Text 3/Local
zip path: /C/Program Files/Sublime Text 3/Packages
zip path: /C/Users/Christian Rickert/AppData/Roaming/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.124581
font face "Roboto Mono" is not monospace, disabling bold and italic to prevent text reflow
first paint time: 0.194581
startup time: 0.212581
[git: tracking working dir]
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.detect_indentation
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.55-jsonschema
reloading plugin Gist.gist_05_import
reloading plugin Gist.gist_20_exceptions
reloading plugin Gist.gist_40_request
reloading plugin Gist.gist_60_helpers
reloading plugin Gist.gist_80
reloading plugin Gist.gitio
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SublimeLinter-annotations.linter
reloading plugin SublimeLinter-gcc.linter
reloading plugin SublimeLinter-pylint.linter
reloading plugin SublimeLinter.__init__
reloading plugin SublimeLinter.active_linters_view
reloading plugin SublimeLinter.busy_indicator_view
reloading plugin SublimeLinter.goto_commands
reloading plugin SublimeLinter.highlight_view
reloading plugin SublimeLinter.log_handler
reloading plugin SublimeLinter.message_view
reloading plugin SublimeLinter.panel_view
reloading plugin SublimeLinter.status_bar_view
reloading plugin SublimeLinter.sublime_linter
plugins loaded
Package Control: Skipping automatic upgrade, last run at 2020-07-27 06:44:22, next run at 2020-07-27 07:44:22 or after

I've now created a small test file to check for common linting issues / errors:

# incorrect function call
print

# line too long
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789

# incorrect function definition
def bla()
    j;asdf  # and variable name

# file not defined
for line in file:
    print(line);  # line not defined

The linting output I now get is this message:

print.py:
 5:12  error  pylint:E0001  invalid syntax (<unknown>, line 5) (syntax-error)

The message is consistent with the Windows command line output, so SublimeLinter-pylint is doing just fine:

C:\Users\Christian Rickert\Desktop>pylint print.py
************* Module print
print.py:5:11: E0001: invalid syntax (<unknown>, line 5) (syntax-error)

Working with an unsaved file is an edge case IMHO, so I would consider this issue as closed:
Would you agree?

@kaste
Copy link
Contributor

kaste commented Jul 27, 2020

Hm. Actually, this plugin here is configured to not run on dirty buffers/views. And we take it for granted that untitled/new buffers are always dirty.

So I need to check this. Do the tabs show the dirty/unsaved dot and still are crashing?

@kaste
Copy link
Contributor

kaste commented Jul 27, 2020

I can see a tiny issue here, although I cannot reproduce the brash/bug. For example, for an untitled file we might call

pylint.EXE "--msg-template='{line}:{column}:{msg_id}: {msg} ({symbol})'" --module-rgx=.* --reports=n --persistent=n ""

(note the "" at the end) but this gives a clean output on my Windows (also newest pylint, python 3.8.0). (So, yea we shouldn't invoke this with an empty filename, but on my system it is only wasteful not harmful.) (You can btw turn on debug mode and see which command we execute in case of a crash.)

@christianrickert
Copy link
Author

christianrickert commented Jul 28, 2020

Interesting! I did a bit of testing and from what I've seen so far:

The issue occurs when creating a new untitled file (no content yet) and then setting the syntax to Python.
It also occurs, when the same untitled and unsaved file is opened up first, when restarting Sublime Text.
And it occurs, even if another python file with content has been opened first.

The issue doesn't occur, if a new untitled file is created, content added (anything, really) and then set to be of type Python.
It also doesn't occur, if the new empty file has been saved to disk first.

Is it possible that Sublime doesn't allocated any buffer/memory for a new unsaved file, when the file has been "created" (new untitled file) but no content has been added or the (empty) file been saved first?

@kaste
Copy link
Contributor

kaste commented Jul 28, 2020

Sublime does some special casing here for sure but you also just found an edge case bug. 💪 I've created a ticket in SublimeLinter core. Probably easy to fix.

@christianrickert
Copy link
Author

Thanks for filing SublimeLinter/SublimeLinter#1761 (comment) .
I'll keep an eye on the progress. - Would you like me to close this issue?

@kaste
Copy link
Contributor

kaste commented Jul 29, 2020

In times of Corona I like it to stay open, it will get closed if a patch lands in core SublimeLinter.

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

No branches or pull requests

2 participants