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

PR: Fix a couple of bugs in the statusbar #15354

Merged
merged 6 commits into from
May 1, 2021

Conversation

steff456
Copy link
Member

@steff456 steff456 commented Apr 20, 2021

Description of Changes

  • This fixes an error of the main window crashing when Kite is installed but not enabled.
  • It also hides completion provider widgets if they are disabled.

Fixes #15322

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: Steff456

@steff456
Copy link
Member Author

@impact27 can you please test this PR with your Spyder settings to see if this change fixes your issue?

@impact27
Copy link
Contributor

It fixes the issue but the autocompletion/linting doesn't work.

@ccordoba12
Copy link
Member

@impact27, that won't work because Spyder needs to be properly installed for our completion architecture to work now.

@impact27
Copy link
Contributor

But couldn't there be a patch if spyder is not part of a proper distribution?
Like if in main() no distribution are detected, we could run:

def patch_spyder_completion():
    """Register completion providers if spyder is not part of a proper distribution."""
    fallback = pkg_resources.EntryPoint.parse(
        'fallback = spyder.plugins.completion.providers.fallback.provider:'
        'FallbackProvider')
    
    snippets = pkg_resources.EntryPoint.parse(
        'snippets = spyder.plugins.completion.providers.snippets.provider:'
        'SnippetsProvider'
    )
    
    lsp = pkg_resources.EntryPoint.parse(
        'lsp = spyder.plugins.completion.providers.languageserver.provider:'
        'LanguageServerProvider'
    )
    
    kite = pkg_resources.EntryPoint.parse(
        'kite = spyder.plugins.completion.providers.kite.provider:'
        'KiteProvider'
    )
    
    # Create a fake Spyder distribution
    d = pkg_resources.Distribution(__file__)
    
    # Add the providers to the fake EntryPoint
    d._ep_map = {
        'spyder.completions': {
            'fallback': fallback,
            'snippets': snippets,
            'lsp': lsp,
            'kite': kite
        }
    }
    
    # Add the fake distribution to the global working_set
    pkg_resources.working_set.add(d, 'spyder')

@impact27
Copy link
Contributor

Or would that just work if I have a local copy of the git?

@impact27
Copy link
Contributor

This works for me: #15382

@ccordoba12
Copy link
Member

@steff456, if the the LSP provider is deactivated in preferences:

imagen

we still try to show its widget in the status bar:

imagen

The idea is to hide it when that provider is disabled. And please do the same for Kite.

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good @steff456, thanks!

spyder/plugins/completion/container.py Outdated Show resolved Hide resolved
spyder/plugins/completion/container.py Outdated Show resolved Hide resolved
spyder/plugins/completion/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/completion/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/completion/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/completion/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/completion/plugin.py Outdated Show resolved Hide resolved
@ccordoba12 ccordoba12 changed the base branch from master to 5.x May 1, 2021 05:26
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @steff456!

@ccordoba12 ccordoba12 changed the title PR: Fix minor bug in statusbar organization PR: Fix a couple of bugs in the statusbar May 1, 2021
@ccordoba12 ccordoba12 merged commit 0ab7bcf into spyder-ide:5.x May 1, 2021
ccordoba12 added a commit that referenced this pull request May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't launch Spyder if Completions plugin is deactivated
3 participants