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

NoneType error on OSx #55

Closed
gerardroche opened this issue May 18, 2024 · 2 comments · Fixed by #57
Closed

NoneType error on OSx #55

gerardroche opened this issue May 18, 2024 · 2 comments · Fixed by #57
Assignees

Comments

@gerardroche
Copy link
Contributor

re: gerardroche/NeoVintageousFiles#2

NeoVintageousFiles has a dependency on SideBarTools. The new folder command is throwing a NoneType error.

This happens when you try to create a new folder when the active view/pane is blank/empty.

Reproduction

  • Create an empty view/pane.
  • Create new folder via NeoVintageousFiles (press A when focus is on the sidebar)
command: neovintageous {"action": "toggle_side_bar"}
command: toggle_side_bar
command: focus_side_bar
chr evt: A (0x41)
command: neovintageous_files_new_folder
command: side_bar_new {"paths": []}
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python38/sublime_plugin.py", line 1647, in run_
    return self.run(**args)
  File "/Users/chris/Library/Application Support/Sublime Text/Installed Packages/SideBarTools.sublime-package/SideBar.py", line 300, in run
  File "./python3.8/genericpath.py", line 42, in isdir
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
reloading settings Packages/User/Preferences.sublime-settings

Relevant line: https://github.com/braver/SideBarTools/blob/master/SideBar.py#L300

Looks like get_path() will return None if the current active view is not a real file on disk.

I'm not sure there is any way to fix this is there? Because until the file name or directory is passed to the command, which is what happens when you use the mouse right click menu, then there is no way for the command discover the path.

Currently, if the file name or directory is not passed, it uses the active view. But if that is not a real file on disk, then it's None.

So this might be a can't fix?

  • ST4 (
  • SideBarTools (1.12.2)
@braver
Copy link
Owner

braver commented May 19, 2024

I believe there is a way to check if a view is a file on disk, and otherwise it sounds like something that might be try-catched. Let’s have a look 😊

braver added a commit that referenced this issue May 20, 2024
@braver
Copy link
Owner

braver commented May 20, 2024

@gerardroche can you check if #56 would help?

@braver braver self-assigned this May 20, 2024
braver added a commit that referenced this issue Jul 18, 2024
@braver braver closed this as completed Jul 18, 2024
gerardroche added a commit to gerardroche/SideBarTools that referenced this issue Jul 19, 2024
The new command uses the active view file name as the path from which to
construct the new folder, but when the view is empty there is no real
file on disk and the file name is None.

The `os.path` functions like `isdir` and `exists` raise a NoneType
exception when given None. This patch adds a NoneType check.

Close braver#55
Re braver#56
braver pushed a commit that referenced this issue Jul 20, 2024
The new command uses the active view file name as the path from which to
construct the new folder, but when the view is empty there is no real
file on disk and the file name is None.

The `os.path` functions like `isdir` and `exists` raise a NoneType
exception when given None. This patch adds a NoneType check.

Close #55
Re #56
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

Successfully merging a pull request may close this issue.

2 participants