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

TypeError: 'NoneType' object is not subscriptable on 'silent! redir => swapfile' #374

Open
Konfekt opened this issue Aug 7, 2021 · 0 comments

Comments

@Konfekt
Copy link

Konfekt commented Aug 7, 2021

This function

function! s:filter_out_swapfile(matched_files)
    silent! redir => swapfile
        silent swapname
    redir END
    let swapfile = fnamemodify(swapfile[1:], ':p')

    return filter(a:matched_files, 'fnamemodify(v:val, ":p") != swapfile')
endfunction

from https://github.com/EinfachToll/DidYouMean/blob/a98fb17ba16aa2eb69b3f9cc7a70e8a736890e4e/plugin/DidYouMean.vim#L6 gives the exception:

Traceback (most recent call last):
  File "/home/konfekt/.local/bin/vint", line 11, in <module>
    sys.exit(main())
    │        └ <function main at 0x7f1fefc41048><module 'sys' (built-in)>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/__init__.py", line 11, in main
    init_cli()
    └ <function init_cli at 0x7f1fec6f6b70>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/bootstrap.py", line 22, in init_cli
    cli.start()
    └ <vint.linting.cli.CLI object at 0x7f1feff44320>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/linting/cli.py", line 27, in start
    violations = self._lint_all(env, config_dict)
                 │              │    └ {'cmdargs': {'verbose': False, 'severity': <Level.WARNING: 1>, 'error-limit': 50, 'stat': False, 'color': False, 'json': False, ...
                 │              └ {'cmdargs': {'verbose': None, 'error': None, 'warning': None, 'style_problem': None, 'max_violations': None, 'color': None, 'no_...
                 └ <vint.linting.cli.CLI object at 0x7f1feff44320>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/linting/cli.py", line 124, in _lint_all
    violations += linter.lint_file(file_path)
    │             │                └ PosixPath('.vim/plugin/DidYouMean.vim')
    │             └ <vint.linting.linter.Linter object at 0x7f1fec459320>
    └ []
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/linting/linter.py", line 107, in lint_file
    root_ast = self._parser.parse_file(path)
               │                       └ PosixPath('.vim/plugin/DidYouMean.vim')
               └ <vint.linting.linter.Linter object at 0x7f1fec459320>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/parsing.py", line 40, in parse_file
    return self.parse(decoded_and_lf_normalized)
           │          └ '" Vim global plugin for selecting the file you actually want to open\n" Maintainer: Daniel Schemala <istjanichtzufassen@gmail.c...
           └ <vint.ast.parsing.Parser object at 0x7f1fec459080>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/parsing.py", line 29, in parse
    plugin.process(ast)
    │              └ {'type': 1, 'pos': {'col': 1, 'i': 0, 'lnum': 1}, 'body': [{'type': 2, 'pos': {'i': 0, 'lnum': 1, 'col': 1, 'offset': 0}, 'str':...
    └ <vint.ast.plugin.scope_plugin.ScopePlugin object at 0x7f1fec4590b8>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/plugin/scope_plugin/__init__.py", line 32, in process
    processed_ast = self._ref_tester.process(ast)
                    │                        └ {'type': 1, 'pos': {'col': 1, 'i': 0, 'lnum': 1}, 'body': [{'type': 2, 'pos': {'i': 0, 'lnum': 1, 'col': 1, 'offset': 0}, 'str':...
                    └ <vint.ast.plugin.scope_plugin.ScopePlugin object at 0x7f1fec4590b8>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/plugin/scope_plugin/reference_reachability_tester.py", line 43, in process
    scope_linker.process(ast)
    │                    └ {'type': 1, 'pos': {'col': 1, 'i': 0, 'lnum': 1}, 'body': [{'type': 2, 'pos': {'i': 0, 'lnum': 1, 'col': 1, 'offset': 0}, 'str':...
    └ <vint.ast.plugin.scope_plugin.scope_linker.ScopeLinker object at 0x7f1fec459588>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/plugin/scope_plugin/scope_linker.py", line 312, in process
    attached_ast = id_classifier.attach_identifier_attributes(ast)
                   │                                          └ {'type': 1, 'pos': {'col': 1, 'i': 0, 'lnum': 1}, 'body': [{'type': 2, 'pos': {'i': 0, 'lnum': 1, 'col': 1, 'offset': 0}, 'str':...
                   └ <vint.ast.plugin.scope_plugin.identifier_classifier.IdentifierClassifier object at 0x7f1fec459860>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/plugin/scope_plugin/identifier_classifier.py", line 122, in attach_identifier_attributes
    ast_with_parsed_redir = redir_assignment_parser.process(ast)
                            │                               └ {'type': 1, 'pos': {'col': 1, 'i': 0, 'lnum': 1}, 'body': [{'type': 2, 'pos': {'i': 0, 'lnum': 1, 'col': 1, 'offset': 0}, 'str':...
                            └ <vint.ast.plugin.scope_plugin.redir_assignment_parser.RedirAssignmentParser object at 0x7f1fec459828>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/plugin/scope_plugin/redir_assignment_parser.py", line 33, in process
    traverse(ast, on_enter=enter_handler)
    │        │             └ <function RedirAssignmentParser.process.<locals>.enter_handler at 0x7f1fec4a5400>
    │        └ {'type': 1, 'pos': {'col': 1, 'i': 0, 'lnum': 1}, 'body': [{'type': 2, 'pos': {'i': 0, 'lnum': 1, 'col': 1, 'offset': 0}, 'str':...
    └ <function traverse at 0x7f1fec81bd90>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 244, in traverse
    node[prop_name])
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 9, in for_each
    call_if_def(func, node)
    │           │     └ {'type': 4, 'pos': {'i': 147, 'lnum': 6, 'col': 1, 'offset': 147}, 'body': [{'type': 3, 'pos': {'i': 206, 'lnum': 7, 'col': 13, ...
    │           └ <function traverse.<locals>.<lambda> at 0x7f1ff17f3a60><function call_if_def at 0x7f1fec81bb70>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 23, in call_if_def
    func(node)
    │    └ {'type': 4, 'pos': {'i': 147, 'lnum': 6, 'col': 1, 'offset': 147}, 'body': [{'type': 3, 'pos': {'i': 206, 'lnum': 7, 'col': 13, ...
    └ <function traverse.<locals>.<lambda> at 0x7f1ff17f3a60>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 243, in <lambda>
    accessor_func(lambda child_node: traverse(child_node, on_enter, on_leave),
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 244, in traverse
    node[prop_name])
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 9, in for_each
    call_if_def(func, node)
    │           │     └ {'type': 3, 'pos': {'i': 206, 'lnum': 7, 'col': 13, 'offset': 206}, 'ea': {'forceit': 0, 'addr_count': 0, 'line1': 0, 'line2': 0...
    │           └ <function traverse.<locals>.<lambda> at 0x7f1fec4c76a8><function call_if_def at 0x7f1fec81bb70>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 1 [DidYouMean.vim]                                                     |~/.config
 23, in call_if_def
    func(node)
    │    └ {'type': 3, 'pos': {'i': 206, 'lnum': 7, 'col': 13, 'offset': 206}, 'ea': {'forceit': 0, 'addr_count': 0, 'line1': 0, 'line2': 0...
 1 [DidYouMean.vim]                                                     |~/.config<function traverse.<locals>.<lambda> at 0x7f1fec4c76a8>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 243, in <lambda>
    accessor_func(lambda child_node: traverse(child_node, on_enter, on_leave),
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 247, in traverse
    handler(node, on_enter=on_enter, on_leave=on_leave)
    │       │              │                  └ None
    │       │              └ <function RedirAssignmentParser.process.<locals>.enter_handler at 0x7f1fec4a5400>
    │       └ {'type': 3, 'pos': {'i': 206, 'lnum': 7, 'col': 13, 'offset': 206}, 'ea': {'forceit': 0, 'addr_count': 0, 'line1': 0, 'line2': 0...
    └ <function traverse_redir_content at 0x7f1fec7a7510>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/plugin/scope_plugin/redir_assignment_parser.py", line 48, in traverse_redir_content
    traverse(node[REDIR_CONTENT], on_enter=on_enter, on_leave=on_leave)
    │        │    │                        │                  └ None
    │        │    │                        └ <function RedirAssignmentParser.process.<locals>.enter_handler at 0x7f1fec4a5400>
    │        │    └ 'VINT:redir_content'
    │        └ {'type': 3, 'pos': {'i': 206, 'lnum': 7, 'col': 13, 'offset': 206}, 'ea': {'forceit': 0, 'addr_count': 0, 'line1': 0, 'line2': 0...
    └ <function traverse at 0x7f1fec81bd90>
  File "/home/konfekt/.local/lib/python3.6/site-packages/vint/ast/traversing.py", line 228, in traverse
    node_type = NodeType(node['type'])
                │        └ None<enum 'NodeType'>
TypeError: 'NoneType' object is not subscriptable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant