Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ runs:
python -m pip install -U ruff
python -m ruff check .
python -m ruff format --check
working-directory: python_files
shell: bash
10 changes: 10 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exclude = [
"src/test/python_files/terminalExec/sample*.py",
"src/testMultiRootWkspc/parent/child/file.py",
"src/testMultiRootWkspc/disableLinters/file.py",
"src/test/python_files/debugging/logMessage.py",
"src/test/python_files/tensorBoard/*.py",
"src/test/python_files/intellisense/test.py",
"src/test/python_files/debugging/*.py",
"src/test/python_files/tensorBoard/tensorboard_import.ipynb"
]
27 changes: 24 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"type": "npm",
"script": "compile",
"isBackground": true,
"problemMatcher": [
"$tsc-watch"
],
"problemMatcher": ["$tsc-watch"],
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -34,6 +32,29 @@
"script": "preTestJediLSP",
"problemMatcher": [],
"label": "preTestJediLSP"
},
{
"label": "Run check_pr.sh",
"type": "shell",
"command": "${workspaceFolder}/check_pr.sh",
"options": {
"cwd": "${workspaceFolder}",
"env": {
"VIRTUAL_ENV": "${workspaceFolder}/.venv",
"PATH": "${workspaceFolder}/.venv/bin/python"
}
},
"group": {
"kind": "build",
"isDefault": false
},
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
}
]
}
11 changes: 6 additions & 5 deletions build/ci/addEnvPath.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

#Adds the virtual environment's executable path to json file
# Adds the virtual environment's executable path to json file

import json
import sys
import os.path

jsonPath = sys.argv[1]
key = sys.argv[2]

if os.path.isfile(jsonPath):
with open(jsonPath, 'r') as read_file:
with open(jsonPath, "r") as read_file:
data = json.load(read_file)
else:
directory = os.path.dirname(jsonPath)
if not os.path.exists(directory):
os.makedirs(directory)
with open(jsonPath, 'w+') as read_file:
with open(jsonPath, "w+") as read_file:
data = {}
data = {}
with open(jsonPath, 'w') as outfile:
if key == 'condaExecPath':
with open(jsonPath, "w") as outfile:
if key == "condaExecPath":
data[key] = sys.argv[3]
else:
data[key] = sys.executable
Expand Down
40 changes: 40 additions & 0 deletions check_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Function to run a command and check its status
run_command() {
echo "Running: '$1'"
echo "----------------------------------------"
$1
if [ $? -ne 0 ]; then
echo "FAILURE: '$1'"
exit 1
else
echo "----------------------------------------"
echo "SUCCESS: '$1'"
echo "----------------------------------------"
fi
}

# Check dependencies
run_command "npm run checkDependencies"

# Run linter
run_command "npm run lint"

# Check formatting
run_command "npm run format-check"

# Activate the virtual environment
source ".venv/bin/activate"

# Change directory to python_files
cd python_files || exit

# Run Pyright
run_command "python -m pyright"

# Run Ruff
run_command "python -m ruff ."
echo "----------------------------------------"
echo "----------------------------------------"
echo "All checks passed successfully!"
1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pathlib
import nox
import shutil
import sys
import sysconfig
import uuid

Expand Down
2 changes: 1 addition & 1 deletion python_files/tests/test_create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def redirect_io(stream: str, new_stream):
class CustomIO(io.TextIOWrapper):
"""Custom stream object to replace stdio."""

name: str = "customio"
name: str = "customio" # type: ignore

def __init__(self, name: str, encoding="utf-8", newline=None):
self._buffer = io.BytesIO()
Expand Down
2 changes: 1 addition & 1 deletion python_files/tests/test_get_variable_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def set_global_variable(value):
# setting on the module allows tests to set a variable that the module under test can access
get_variable_info.test_variable = value # pyright: ignore[reportGeneralTypeIssues]
get_variable_info.test_variable = value # pyright: ignore[reportGeneralTypeIssues] # type: ignore


def get_global_variable():
Expand Down
47 changes: 23 additions & 24 deletions src/test/multiRootWkspc/disableLinters/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__revision__ = None


class Foo(object):
"""block-disable test"""

Expand All @@ -15,73 +16,71 @@ def meth1(self, arg):
def meth2(self, arg):
"""and this one not"""
# pylint: disable=unused-argument
print (self\
+ "foo")
print(self + "foo")

def meth3(self):
"""test one line disabling"""
# no error
print (self.bla) # pylint: disable=no-member
print(self.bla) # pylint: disable=no-member
# error
print (self.blop)
print(self.blop)

def meth4(self):
"""test re-enabling"""
# pylint: disable=no-member
# no error
print (self.bla)
print (self.blop)
print(self.bla)
print(self.blop)
# pylint: enable=no-member
# error
print (self.blip)
print(self.blip)

def meth5(self):
"""test IF sub-block re-enabling"""
# pylint: disable=no-member
# no error
print (self.bla)
print(self.bla)
if self.blop:
# pylint: enable=no-member
# error
print (self.blip)
print(self.blip)
else:
# no error
print (self.blip)
print(self.blip)
# no error
print (self.blip)
print(self.blip)

def meth6(self):
"""test TRY/EXCEPT sub-block re-enabling"""
# pylint: disable=no-member
# no error
print (self.bla)
print(self.bla)
try:
# pylint: enable=no-member
# error
print (self.blip)
except UndefinedName: # pylint: disable=undefined-variable
print(self.blip)
except UndefinedName: # type: ignore # pylint: disable=undefined-variable # noqa: F821
# no error
print (self.blip)
print(self.blip)
# no error
print (self.blip)
print(self.blip)

def meth7(self):
"""test one line block opening disabling"""
if self.blop: # pylint: disable=no-member
if self.blop: # pylint: disable=no-member
# error
print (self.blip)
print(self.blip)
else:
# error
print (self.blip)
print(self.blip)
# error
print (self.blip)

print(self.blip)

def meth8(self):
"""test late disabling"""
# error
print (self.blip)
print(self.blip)
# pylint: disable=no-member
# no error
print (self.bla)
print (self.blop)
print(self.bla)
print(self.blop)
3 changes: 2 additions & 1 deletion src/test/multiRootWkspc/parent/child/childFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__revision__ = None


class Child2Class(object):
"""block-disable test"""

Expand All @@ -10,4 +11,4 @@ def __init__(self):

def meth1OfChild(self, arg):
"""this issues a message"""
print (self)
print(self)
47 changes: 23 additions & 24 deletions src/test/multiRootWkspc/parent/child/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__revision__ = None


class Foo(object):
"""block-disable test"""

Expand All @@ -15,73 +16,71 @@ def meth1(self, arg):
def meth2(self, arg):
"""and this one not"""
# pylint: disable=unused-argument
print (self\
+ "foo")
print(self + "foo")

def meth3(self):
"""test one line disabling"""
# no error
print (self.bla) # pylint: disable=no-member
print(self.bla) # pylint: disable=no-member
# error
print (self.blop)
print(self.blop)

def meth4(self):
"""test re-enabling"""
# pylint: disable=no-member
# no error
print (self.bla)
print (self.blop)
print(self.bla)
print(self.blop)
# pylint: enable=no-member
# error
print (self.blip)
print(self.blip)

def meth5(self):
"""test IF sub-block re-enabling"""
# pylint: disable=no-member
# no error
print (self.bla)
print(self.bla)
if self.blop:
# pylint: enable=no-member
# error
print (self.blip)
print(self.blip)
else:
# no error
print (self.blip)
print(self.blip)
# no error
print (self.blip)
print(self.blip)

def meth6(self):
"""test TRY/EXCEPT sub-block re-enabling"""
# pylint: disable=no-member
# no error
print (self.bla)
print(self.bla)
try:
# pylint: enable=no-member
# error
print (self.blip)
except UndefinedName: # pylint: disable=undefined-variable
print(self.blip)
except UndefinedName: # type: ignore # pylint: disable=undefined-variable # noqa: F821
# no error
print (self.blip)
print(self.blip)
# no error
print (self.blip)
print(self.blip)

def meth7(self):
"""test one line block opening disabling"""
if self.blop: # pylint: disable=no-member
if self.blop: # pylint: disable=no-member
# error
print (self.blip)
print(self.blip)
else:
# error
print (self.blip)
print(self.blip)
# error
print (self.blip)

print(self.blip)

def meth8(self):
"""test late disabling"""
# error
print (self.blip)
print(self.blip)
# pylint: disable=no-member
# no error
print (self.bla)
print (self.blop)
print(self.bla)
print(self.blop)
Loading
Loading