Skip to content

Commit

Permalink
run latest black
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuDartiailh committed Feb 24, 2023
1 parent 67744e5 commit 19a5061
Show file tree
Hide file tree
Showing 14 changed files with 5 additions and 47 deletions.
1 change: 0 additions & 1 deletion pyvisa/ctwrapper/cthelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# On Linux, find Library returns the name not the path.
# This excerpt provides a modified find_library.
if os.name == "posix" and sys.platform.startswith("linux"):

# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
def define_find_libary():
import errno
Expand Down
3 changes: 1 addition & 2 deletions pyvisa/ctwrapper/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,6 @@ def install_handler(
)

with set_user_handle_type(library, converted_user_handle):

if ctwrapper.WRAP_HANDLER:
# Wrap the handler to provide a non-wrapper specific interface
def handler_wrapper(
Expand Down Expand Up @@ -2096,7 +2095,7 @@ def parse_resource_extended(library, session, resource_name):
ResourceInfo(
constants.InterfaceType(interface_type.value),
interface_board_number.value,
*res
*res,
),
ret,
)
Expand Down
1 change: 0 additions & 1 deletion pyvisa/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def register(
"""Register a class with a given event type."""

def _internal(python_class: Type["Event"]) -> Type["Event"]:

if event_type in cls._event_classes:
logger.warning(
"%s is already registered. "
Expand Down
1 change: 0 additions & 1 deletion pyvisa/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,6 @@ def list_backends() -> List[str]:


class PyVISAModule(ModuleType):

WRAPPER_CLASS: Type[VisaLibraryBase]


Expand Down
1 change: 0 additions & 1 deletion pyvisa/resources/messagebased.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def read_termination(self) -> Optional[str]:

@read_termination.setter
def read_termination(self, value: str) -> None:

if value:
# termination character, the rest is just used for verification
# after each read operation.
Expand Down
1 change: 0 additions & 1 deletion pyvisa/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def register(
"""

def _internal(python_class):

highlevel.ResourceManager.register_resource_class(
interface_type, resource_class, python_class
)
Expand Down
2 changes: 0 additions & 2 deletions pyvisa/rname.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def register_subclass(cls: T) -> T:
fmt = OrderedDict([("interface_type", cls.interface_type)])
syntax = cls.interface_type
for ndx, f in enumerate(fields(cls)):

sep = "::" if ndx else ""

fmt[f.name] = sep + "{0}"
Expand Down Expand Up @@ -207,7 +206,6 @@ def from_string(cls, resource_name: str) -> "ResourceName":
uname = resource_name.upper()

for interface_type in _INTERFACE_TYPES:

# Loop through all known interface types until we found one
# that matches the beginning of the resource name
if not uname.startswith(interface_type):
Expand Down
1 change: 0 additions & 1 deletion pyvisa/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def emit(self, record):


class BaseTestCase:

CHECK_NO_WARNING = True

def setup_method(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def teardown_method(self):
self.rm.close()

def _test_filter2(self, expr, *correct):

resources = self.rm.list_resources(expr.split("{")[0])
ok = tuple(resources[n] for n in correct)
filtered = rname.filter2(
Expand Down
1 change: 0 additions & 1 deletion pyvisa/testsuite/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

class TestDataWidth(BaseTestCase):
def test_conversion_from_literal(self):

for v, e in zip(
(8, 16, 32, 64),
(DataWidth.bit_8, DataWidth.bit_16, DataWidth.bit_32, DataWidth.bit_64),
Expand Down
2 changes: 0 additions & 2 deletions pyvisa/testsuite/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def teardown_method(self):
Event._event_classes = self.old

def test_register(self):

assert Event._event_classes[constants.EventType.clear] is Event

def test_double_register_event_cls(self, caplog):
Expand All @@ -51,7 +50,6 @@ class SubEvent(Event):
assert Event._event_classes[constants.EventType.exception] is not SubEvent

def test_event_context(self):

event = Event(None, constants.EventType.clear, 1)
assert event.context == 1

Expand Down
3 changes: 0 additions & 3 deletions pyvisa/testsuite/test_rname.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ def test_gpib_intf(self):
)

def test_tcpip_intr(self):

self._parse_test(
"TCPIP::192.168.134.102",
interface_type="TCPIP",
Expand Down Expand Up @@ -296,7 +295,6 @@ def test_tcpip_intr(self):
)

def test_vicp_intr(self):

self._parse_test(
"VICP::192.168.134.102",
interface_type="VICP",
Expand Down Expand Up @@ -466,7 +464,6 @@ def test_usb_raw(self):


class TestFilters(BaseTestCase):

CHECK_NO_WARNING = False

run_list = (
Expand Down
1 change: 0 additions & 1 deletion pyvisa/testsuite/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ def get_debug_info(cls):


def generate_fakelibs(dirname):

for name, blob in zip(
[
"fakelib_bad_magic.dll",
Expand Down
33 changes: 4 additions & 29 deletions pyvisa/thirdparty/prettytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def _get_size(text):

class PrettyTable(object):
def __init__(self, field_names=None, **kwargs):

"""Return a new PrettyTable instance
Arguments:
Expand Down Expand Up @@ -239,7 +238,6 @@ def _justify(self, text, width, align):
return (excess // 2) * " " + text + (excess // 2) * " "

def __getattr__(self, name):

if name == "rowcount":
return len(self._rows)
elif name == "colcount":
Expand All @@ -253,7 +251,6 @@ def __getattr__(self, name):
raise AttributeError(name)

def __getitem__(self, index):

new = PrettyTable()
new.field_names = self.field_names
for attr in self._options:
Expand Down Expand Up @@ -951,7 +948,6 @@ def oldsortslice(self, val):
##############################

def _get_options(self, kwargs):

options = {}
for option in self._options:
if option in kwargs:
Expand All @@ -966,7 +962,6 @@ def _get_options(self, kwargs):
##############################

def set_style(self, style):

if style == DEFAULT:
self._set_default_style()
elif style == MSWORD_FRIENDLY:
Expand All @@ -991,7 +986,6 @@ def _set_markdown_style(self):
self.junction_char = "|"

def _set_default_style(self):

self.header = True
self.border = True
self._hrules = FRAME
Expand All @@ -1004,7 +998,6 @@ def _set_default_style(self):
self.junction_char = "+"

def _set_msword_style(self):

self.header = True
self.border = True
self._hrules = NONE
Expand All @@ -1014,15 +1007,13 @@ def _set_msword_style(self):
self.vertical_char = "|"

def _set_columns_style(self):

self.header = True
self.border = False
self.padding_width = 1
self.left_padding_width = 0
self.right_padding_width = 8

def _set_random_style(self):

# Just for fun!
self.header = random.choice((True, False))
self.border = random.choice((True, False))
Expand All @@ -1039,7 +1030,6 @@ def _set_random_style(self):
##############################

def add_row(self, row):

"""Add a row to the table
Arguments:
Expand All @@ -1057,7 +1047,6 @@ def add_row(self, row):
self._rows.append(list(row))

def del_row(self, row_index):

"""Delete a row to the table
Arguments:
Expand All @@ -1072,7 +1061,6 @@ def del_row(self, row_index):
del self._rows[row_index]

def add_column(self, fieldname, column, align="c", valign="t"):

"""Add a column to the table.
Arguments:
Expand Down Expand Up @@ -1102,13 +1090,11 @@ def add_column(self, fieldname, column, align="c", valign="t"):
)

def clear_rows(self):

"""Delete all rows from the table but keep the current field names"""

self._rows = []

def clear(self):

"""Delete all rows and field names from the table, maintaining nothing but
styling options"""

Expand Down Expand Up @@ -1193,7 +1179,6 @@ def _compute_widths(self, rows, options):
self._widths = widths

def _get_padding_widths(self, options):

if options["left_padding_width"] is not None:
lpad = options["left_padding_width"]
else:
Expand Down Expand Up @@ -1247,7 +1232,6 @@ def _format_rows(self, rows, options):
##############################

def get_string(self, **kwargs):

"""Return string representation of table in current state.
Arguments:
Expand Down Expand Up @@ -1318,7 +1302,6 @@ def get_string(self, **kwargs):
return self._unicode("\n").join(lines)

def _stringify_hrule(self, options):

if not options["border"]:
return ""
lpad, rpad = self._get_padding_widths(options)
Expand All @@ -1344,7 +1327,6 @@ def _stringify_hrule(self, options):
return "".join(bits)

def _stringify_title(self, title, options):

lines = []
lpad, rpad = self._get_padding_widths(options)
if options["border"]:
Expand All @@ -1366,7 +1348,6 @@ def _stringify_title(self, title, options):
return "\n".join(lines)

def _stringify_header(self, options):

bits = []
lpad, rpad = self._get_padding_widths(options)
if options["border"]:
Expand All @@ -1383,7 +1364,7 @@ def _stringify_header(self, options):
bits.append(options["vertical_char"])
else:
bits.append(" ")
for (field, width) in zip(self._field_names, self._widths):
for field, width in zip(self._field_names, self._widths):
if options["fields"] and field not in options["fields"]:
continue
if self._header_style == "cap":
Expand Down Expand Up @@ -1417,8 +1398,7 @@ def _stringify_header(self, options):
return "".join(bits)

def _stringify_row(self, row, options):

for (index, field, value, width) in zip(
for index, field, value, width in zip(
range(0, len(row)), self._field_names, row, self._widths
):
# Enforce max widths
Expand Down Expand Up @@ -1448,8 +1428,7 @@ def _stringify_row(self, row, options):
else:
bits[y].append(" ")

for (field, value, width) in zip(self._field_names, row, self._widths):

for field, value, width in zip(self._field_names, row, self._widths):
valign = self._valign[field]
lines = value.split("\n")
dHeight = row_height - len(lines)
Expand Down Expand Up @@ -1499,7 +1478,6 @@ def _stringify_row(self, row, options):
return "\n".join(bits)

def paginate(self, page_length=58, **kwargs):

pages = []
kwargs["start"] = kwargs.get("start", 0)
true_end = kwargs.get("end", self.rowcount)
Expand All @@ -1515,7 +1493,6 @@ def paginate(self, page_length=58, **kwargs):
# JSON STRING METHODS #
##############################
def get_json_string(self, **kwargs):

"""Return string representation of JSON formatted table in the current state
Arguments:
Expand Down Expand Up @@ -1572,7 +1549,6 @@ def get_html_string(self, **kwargs):
return string

def _get_simple_html_string(self, options):

lines = []
if options["xhtml"]:
linebreak = "<br/>"
Expand Down Expand Up @@ -1627,7 +1603,6 @@ def _get_simple_html_string(self, options):
return self._unicode("\n").join(lines)

def _get_formatted_html_string(self, options):

lines = []
lpad, rpad = self._get_padding_widths(options)
if options["xhtml"]:
Expand Down Expand Up @@ -1836,7 +1811,7 @@ def handle_starttag(self, tag, attrs):
self.active = tag
if tag == "th":
self.is_last_row_header = True
for (key, value) in attrs:
for key, value in attrs:
if key == "colspan":
self.colspan = int(value)

Expand Down

0 comments on commit 19a5061

Please sign in to comment.