dzhibas / SublimePrettyJson

Prettify/Minify/Query/Goto/Validate/Lint JSON plugin for Sublime Text 3 & 4
MIT License
2.03k stars 180 forks source link

Add bits of None- and type-safety to the plugin code #181

Closed ratijas closed 3 months ago

ratijas commented 9 months ago

Fixed #180

mortalis13 commented 6 months ago

Thanks for posting it. I also found this on saving json files.

But I think just assigning self.view = view in both listeners would be a quick valid solution, in PrettyJsonListeners.py.

As yours gives me another error on save (which I don't know where it comes from...):

Traceback (most recent call last):
  File "D:\Program Files\Sublime Text\Lib\python38\sublime_plugin.py", line 1691, in run_
    edit = self.view.begin_edit(edit_token, self.name())
AttributeError: 'NoneType' object has no attribute 'begin_edit'

The view is intended to be provided by the base plugin class instances, so PrettyJsonBaseCommand is a mixin which has access to the view. But PrettyJsonLintListener doesn't have view attribute self.view, so it cannot pass it to its mixin instance of PrettyJsonBaseCommand. That's why def on_post_save(self, view): has view as argument.

So I'd say it's incorrectly inherits from PrettyJsonBaseCommand and it would need to be redesigned, maybe using a constructor argument as in your code, but creating an instance from the listener method, but the commands should also do it, instead of inheriting the mixin.

mortalis13 commented 6 months ago

Anyway, this seems an abandoned project, so I'll use my fork for me, and will create a clone package on package control some day, if someone else doesn't do it until then...

ratijas commented 6 months ago

The fact I already forgot about my PR and the fact that it's still not merged is a certified GitHub momentâ„¢

Projects like this should be moved under bigger organizations / umbrellas with a pool of maintainers and on-boarding/off-boarding processes.

deathaxe commented 3 months ago

This PR is obsolete.

ratijas commented 3 months ago

cool, thanks!