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

Add Pylance support #306

Closed
wants to merge 1 commit into from
Closed

Add Pylance support #306

wants to merge 1 commit into from

Conversation

mwelcker
Copy link

I just added Pylance autocompletion support.
Pylance uses python.analysis.extraPaths instead of python.autoComplete.extraPaths.

Fix #152

@BradenM
Copy link
Owner

BradenM commented Sep 25, 2022

@mwelcker Thank you for the PR.

Great start, but based on #152 (comment) I'm not sure if just adding python.analysis.extraPaths to the template is the best move.

One idea for handling this could be to add a "language-server" parameter to the jinja2 context used for rendering the file.
You could then add a new template class ("PylanceCodeTemplate" or something) that overloads the existing CodeTemplate class context property

class CodeTemplate(Template):
"""Template for VSCode settings."""
FILENAME = ".vscode/settings.json"
CHECKS = [TEMPLATE_CHECKS["ms-python"]]
def __init__(self, *args, **kwargs):
self.update_method = self.update_as_json
super().__init__(*args, **kwargs)
@property
def context(self):
"""VScode Config Context."""
paths = self.paths
if self.datadir:
paths = list(self.iter_relative_paths(self.paths, strict=True))
if self.local_paths:
paths.extend(self.iter_relative_paths(self.local_paths))
stub_paths = json.dumps([str(s) for s in paths])
ctx = {
"stubs": self.stubs or [],
"paths": stub_paths,
}
return ctx

and sets the property to pylance. You could then extend the jinja template to check for this parameter and render the optimal configuration (based on the discussion in #152).

Lemme know what you think, thanks.

@codecov
Copy link

codecov bot commented Dec 11, 2022

Codecov Report

Base: 93.58% // Head: 93.46% // Decreases project coverage by -0.13% ⚠️

Coverage data is based on head (4532004) compared to base (65ef13b).
Patch has no changes to coverable lines.

❗ Current head 4532004 differs from pull request most recent head ee3fc07. Consider uploading reports for the commit ee3fc07 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
- Coverage   93.58%   93.46%   -0.13%     
==========================================
  Files          50       48       -2     
  Lines        2652     2618      -34     
==========================================
- Hits         2482     2447      -35     
- Misses        170      171       +1     
Flag Coverage Δ
os-macOS-12 ?
os-ubuntu-latest ?
os-windows-latest ?
py-3.10 ?
py-3.11 ?
py-3.7 ?
py-3.8 ?
py-3.9 ?
unittests 93.46% <0.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
micropy/stubs/repo_package.py 70.73% <0.00%> (-19.52%) ⬇️
micropy/stubs/manifest.py 94.44% <0.00%> (-5.56%) ⬇️
micropy/stubs/repositories/micropython.py 77.41% <0.00%> (-3.23%) ⬇️
micropy/stubs/repo.py 89.70% <0.00%> (-2.95%) ⬇️
micropy/project/template.py 97.56% <0.00%> (-0.61%) ⬇️
micropy/cli.py 95.26% <0.00%> (-0.06%) ⬇️
micropy/__init__.py 100.00% <0.00%> (ø)
micropy/utils/helpers.py 93.85% <0.00%> (ø)
micropy/utils/_compat.py
micropy/__main__.py
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@BradenM
Copy link
Owner

BradenM commented Jan 30, 2023

In favor of #379

@BradenM BradenM closed this Jan 30, 2023
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 this pull request may close these issues.

Pylance Support
2 participants