Skip to content

Commit

Permalink
attempt to format all files with ruff? idk
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Oct 31, 2024
1 parent 1bc72ba commit ebe56be
Show file tree
Hide file tree
Showing 22 changed files with 104 additions and 94 deletions.
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
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
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: # type: ignore # pylint: disable=undefined-variable # noqa: F821
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)
3 changes: 2 additions & 1 deletion src/test/multiRootWkspc/workspace2/workspace2File.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__revision__ = None


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

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

def meth1OfWorkspace2(self, arg):
"""this issues a message"""
print (self)
print(self)
47 changes: 23 additions & 24 deletions src/test/multiRootWkspc/workspace3/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: # type: ignore # pylint: disable=undefined-variable # noqa: F821
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)
2 changes: 1 addition & 1 deletion src/test/pythonFiles/dummy.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#dummy file to be opened by Test VS Code instance, so that Python Configuration (workspace configuration will be initialized)
# dummy file to be opened by Test VS Code instance, so that Python Configuration (workspace configuration will be initialized)
6 changes: 3 additions & 3 deletions src/test/python_files/datascience/simple_note_book.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# %%
import os.path
dir_path = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(dir_path, 'ds.log'), 'a') as fp:
fp.write('Hello World')
dir_path = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(dir_path, "ds.log"), "a") as fp:
fp.write("Hello World")
2 changes: 1 addition & 1 deletion src/test/python_files/dummy.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#dummy file to be opened by Test VS Code instance, so that Python Configuration (workspace configuration will be initialized)
# dummy file to be opened by Test VS Code instance, so that Python Configuration (workspace configuration will be initialized)
1 change: 0 additions & 1 deletion src/test/python_files/shebang/plain.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

print("dummy")
3 changes: 2 additions & 1 deletion src/testMultiRootWkspc/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)
6 changes: 3 additions & 3 deletions src/testMultiRootWkspc/smokeTests/create_delete_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
with open('smart_send_smoke.txt', 'w') as f:
f.write('This is for smart send smoke test')
with open("smart_send_smoke.txt", "w") as f:
f.write("This is for smart send smoke test")
import os

os.remove('smart_send_smoke.txt')
os.remove("smart_send_smoke.txt")
6 changes: 6 additions & 0 deletions src/testMultiRootWkspc/smokeTests/definitions.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
from contextlib import contextmanager


def my_decorator(fn):
"""
This is my decorator.
"""

def wrapper(*args, **kwargs):
"""
This is the wrapper.
"""
return 42

return wrapper


@my_decorator
def thing(arg):
"""
Thing which is decorated.
"""
pass


@contextmanager
def my_context_manager():
"""
Expand All @@ -27,5 +32,6 @@ def my_context_manager():
yield
print("after")


with my_context_manager():
thing(19)
4 changes: 2 additions & 2 deletions src/testMultiRootWkspc/smokeTests/testExecInTerminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import sys
import os

optlist, args = getopt.getopt(sys.argv, '')
optlist, args = getopt.getopt(sys.argv, "")

# If the caller has not specified the output file, create one for them with
# the same name as the caller script, but with a .log extension.
log_file = os.path.splitext(sys.argv[0])[0] + '.log'
log_file = os.path.splitext(sys.argv[0])[0] + ".log"

# If the output file is given, use that instead.
if len(args) == 2:
Expand Down
Loading

0 comments on commit ebe56be

Please sign in to comment.