ianding1 / leetcode.vim

Solve LeetCode problems in Vim!
MIT License
300 stars 43 forks source link

Failed to run test and submit #31

Closed crokobit closed 4 years ago

crokobit commented 4 years ago

After LeetCodeSubmit command:

error: 'NoneType' object is not subscriptable

After LeetCodeTest command:

Error detected while processing function leetcode#TestSolution[17]..provider#python3#Call:
line   18:
Error invoking 'python_eval' on channel 4 (python3-script-host):
error caught in request handler 'python_eval ['leetcode.get_problem("1")']':
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pynvim/plugin/script_host.py", line 165, in python_eval
    return eval(expr, self.module.__dict__)
  File "<string>", line 1, in <module>
  File "/Users/crokobit/.vim/plugged/leetcode.vim/autoload/leetcode.py", line 246, in get_problem
    content = q['translatedContent'] or q['content']
TypeError: 'NoneType' object is not subscriptable
jamak commented 4 years ago

I also have this issue, on macOS Catalina with vim 8.1 and the mostt recent version of leetcode.vim

ywpkwon commented 4 years ago

I also have this issue, on Ubuntu 18.04 with neovim v0.4.2

ianding1 commented 4 years ago

Investigating...

ywpkwon commented 4 years ago

Thanks for investigating. Why do they keep changing APIs...? :(

ianding1 commented 4 years ago

It turns out that the code failed to detect when the session cookie is expired.

This commit should have fixed the problem: 8cb81b57ceb110918663ca8bc6dc3c87a511a3b5

Please let me know if it does not work.

crokobit commented 4 years ago

@ianding1 Still got same error.

ianding1 commented 4 years ago

Hi, @crokobit i noticed that in the error message the argument passed to leetcode.get_problem was "1" while it should have been a slug, for example, "two-sum". So i'd like to know if the file name was modified.

Currently we guess the problem slug from the file name. For example, if the file name is two-sum.c, then we will assume that the problem is two-sum.

crokobit commented 4 years ago

@ianding1 Not sure what "the file name was modified." means. But the file name does be the same as the slug of that question. e.g. two-sum.rb. I didn't modify the name of that file.

Tried the commit @Wilnath did by modify package code directly but still got the same result.

Wilnath commented 4 years ago

@crokobit Do new problems you download have the problem id before the name? something like 1.two_sum.cpp. The problem I was having that @ianding1 described is the problem id getting sent instead of the slug.

I assumed that all new files get the problem id as a prefix but if that isn't the case my commit doesn't really help 😅

Edit: There's an identical problem described in #32 at line 898, with SubmitSolution this time

crokobit commented 4 years ago

@Wilnath What I mentioned in the previous comment is wrong. My file name did have the prefix. like 1.two_sum.cpp. But still got error even with @Wilnath 's fix.

ianding1 commented 4 years ago

It looks like that the file name change brought some troubles.

Thanks to @Wilnath for pointing out the cause.

To summarize what has happened, leetcode.vim used to create files in two formats, taking TwoSum as example, two_sum.c and two_sum.1234.c where the latter is for a specific submission 1234.

Recently leetcode.vim prepended the problem ID to the file name, so we have a new file name 1.two_sum.c.

Unfortunately, leetcode.vim didn't modify other parts accordingly, such as testing and submission.

With this fix 4aaec9fd5c0b0dd8, the problem should be gone.

I'm very sorry for all the inconvenience and frustrations caused by this bug. I'll learn from it and pay attention to breaking changes in the future.

I hope you enjoy and keep supporting leetcode.vim.

crokobit commented 4 years ago

@ianding1 It works! really thank you for your efforts in doing this amazing plugin! :)

linweilin commented 1 year ago

Still get the same error on WSL2 Ubuntu 22.04

Error detected while processing function leetcode#ListProblems[2]..<SNR>67_CheckSignIn[2]..leetcode#SignIn[1]..<SNR>67_LoadSessionCookie[6]..provider#python3#Call:
line   18:
Error invoking 'python_eval' on channel 4 (python3-script-host):
error caught in request handler 'python_eval ['leetcode.load_session_cookie("chrome")']':
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pynvim/plugin/script_host.py", line 171, in python_eval
    return eval(expr, self.module.__dict__)
  File "<string>", line 1, in <module>
  File "/home/william/.config/nvim/plugged/leetcode.vim/autoload/leetcode.py", line 168, in load_session_cookie
    session_cookie_raw = keyring.get_password('leetcode.vim', 'SESSION_COOKIE')
  File "/usr/lib/python3/dist-packages/keyring/core.py", line 55, in get_password
    return get_keyring().get_password(service_name, username)
  File "/usr/lib/python3/dist-packages/keyring/backends/fail.py", line 25, in get_password
    raise NoKeyringError(msg)
keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt pac
kage if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.