Skip to content

Commit

Permalink
Fix up CI problems due to new black rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Mar 6, 2023
1 parent 1ea33ab commit ce8e720
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.1.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort
4 changes: 0 additions & 4 deletions src/smbclient/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ def commit(self):


class SMBRawIO(io.RawIOBase):

FILE_TYPE = None # 'file', 'dir', or None (for unknown)
_INVALID_MODE = ""

Expand Down Expand Up @@ -601,7 +600,6 @@ def write(self, b):


class SMBDirectoryIO(SMBRawIO):

FILE_TYPE = "dir"
_INVALID_MODE = "w+"

Expand All @@ -628,12 +626,10 @@ def writable(self):


class SMBFileIO(SMBRawIO):

FILE_TYPE = "file"


class SMBPipeIO(SMBRawIO):

FILE_TYPE = "pipe"

def seekable(self):
Expand Down
20 changes: 10 additions & 10 deletions src/smbclient/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def link(src, dst, follow_symlinks=True, **kwargs):
share_access="rwd",
desired_access=FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES,
create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT,
**kwargs
**kwargs,
)
with SMBFileTransaction(raw) as transaction:
link_info = FileLinkInformation()
Expand Down Expand Up @@ -318,7 +318,7 @@ def open_file(
desired_access=None,
file_attributes=None,
file_type="file",
**kwargs
**kwargs,
):
"""
Open a file on an SMB share and return a corresponding file object. If the file cannot be opened, an OSError is
Expand Down Expand Up @@ -385,7 +385,7 @@ def open_file(
share_access=share_access,
desired_access=desired_access,
file_attributes=file_attributes,
**kwargs
**kwargs,
)
try:
raw_fd.open()
Expand Down Expand Up @@ -581,7 +581,7 @@ def stat(path, follow_symlinks=True, **kwargs):
share_access="rwd",
desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES,
create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT,
**kwargs
**kwargs,
)
with SMBFileTransaction(raw) as transaction:
query_info(transaction, FileBasicInformation)
Expand Down Expand Up @@ -998,7 +998,7 @@ def setxattr(path, attribute, value, flags=0, follow_symlinks=True, **kwargs):
share_access="r",
desired_access=FilePipePrinterAccessMask.FILE_WRITE_EA,
create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT,
**kwargs
**kwargs,
)
with SMBFileTransaction(raw) as transaction:
ea_info = FileFullEaInformation()
Expand All @@ -1023,7 +1023,7 @@ def _delete(raw_type, path, **kwargs):
share_access="rwd",
desired_access=FilePipePrinterAccessMask.DELETE | FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES,
create_options=co,
**kwargs
**kwargs,
)

with SMBFileTransaction(raw) as transaction:
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def _get_extended_attributes(path, follow_symlinks=True, **kwargs):
share_access="r",
desired_access=FilePipePrinterAccessMask.FILE_READ_EA,
create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT,
**kwargs
**kwargs,
)

try:
Expand All @@ -1079,7 +1079,7 @@ def _get_reparse_point(path, **kwargs):
mode="r",
desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES,
create_options=CreateOptions.FILE_OPEN_REPARSE_POINT,
**kwargs
**kwargs,
)

with SMBFileTransaction(raw) as transaction:
Expand Down Expand Up @@ -1151,15 +1151,15 @@ def _set_basic_information(
change_time=0,
file_attributes=0,
follow_symlinks=True,
**kwargs
**kwargs,
):
raw = SMBRawIO(
path,
mode="r",
share_access="rwd",
desired_access=FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES,
create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT,
**kwargs
**kwargs,
)

with SMBFileTransaction(raw) as transaction:
Expand Down
2 changes: 1 addition & 1 deletion src/smbclient/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
skip_dfs=False,
auth_protocol="negotiate",
require_secure_negotiate=True,
**kwargs
**kwargs,
):
self.client_guid = client_guid or uuid.uuid4()
self.username = username
Expand Down
8 changes: 4 additions & 4 deletions src/smbclient/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def copytree(
copy_function=copy2,
ignore_dangling_symlinks=False,
dirs_exist_ok=False,
**kwargs
**kwargs,
):
"""
Recursively copy an entire directory tree rooted at src to a directory named dst and return the destination
Expand Down Expand Up @@ -335,7 +335,7 @@ def copytree(
copy_function,
ignore_dangling_symlinks,
dirs_exist_ok,
**kwargs
**kwargs,
)
else:
copy_function(src_path, dst_path, **kwargs)
Expand Down Expand Up @@ -464,7 +464,7 @@ def _set_file_basic_info(file_path, follow_symlinks, read_only=None, atime_ns=No
share_access="rw",
create_options=co,
desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES,
**kwargs
**kwargs,
)
with SMBFileTransaction(file_fd) as transaction:
query_info(transaction, FileBasicInformation)
Expand All @@ -487,7 +487,7 @@ def _set_file_basic_info(file_path, follow_symlinks, read_only=None, atime_ns=No
share_access="rw",
create_options=co,
desired_access=FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES,
**kwargs
**kwargs,
)

with SMBFileTransaction(file_fd) as transaction:
Expand Down
2 changes: 0 additions & 2 deletions src/smbprotocol/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ def _get_field(self, key):


class DateTimeField(Field):

EPOCH_FILETIME = 116444736000000000 # epoch as a MS FILETIME int

def __init__(self, size=None, **kwargs):
Expand Down Expand Up @@ -668,7 +667,6 @@ def _parse_value(self, value):
int_value = struct.unpack(struct_string, value)[0]
return self._parse_value(int_value) # just parse the value again
elif isinstance(value, int):

time_microseconds = (value - self.EPOCH_FILETIME) // 10
try:
datetime_value = datetime.datetime(1970, 1, 1) + datetime.timedelta(microseconds=time_microseconds)
Expand Down
1 change: 0 additions & 1 deletion src/smbprotocol/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self):


class Tcp(object):

MAX_SIZE = 16777215

def __init__(self, server, port, timeout=None):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_change_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@


class TestFileNotifyInformation(object):

DATA = b"\x00\x00\x00\x00" b"\x01\x00\x00\x00" b"\x08\x00\x00\x00" b"\x63\x00\x61\x00\x66\x00\xe9\x00"

def test_create_message(self):
Expand All @@ -55,7 +54,6 @@ def test_parse_message(self):


class TestSMB2ChangeNotifyRequest(object):

DATA = (
b"\x20\x00"
b"\x00\x00"
Expand Down Expand Up @@ -88,7 +86,6 @@ def test_parse_message(self):


class TestSMB2ChangeNotifyResponse(object):

DATA = b"\x09\x00" b"\x48\x00" b"\x04\x00\x00\x00" b"\x01\x02\x03\x04"

def test_create_message(self):
Expand Down
1 change: 0 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ def test_parse_message(self):


class TestSMB2CancelRequest(object):

DATA = b"\x04\x00" b"\x00\x00"

def test_create_message(self):
Expand Down
10 changes: 0 additions & 10 deletions tests/test_file_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@


class TestFileNameInformation(object):

DATA = b"\x08\x00\x00\x00" b"\x63\x00\x61\x00\x66\x00\xe9\x00"

def test_create_message(self):
Expand All @@ -51,7 +50,6 @@ def test_parse_message(self):


class TestFileAllInformation(object):

DATA = (
b"\x00\x80\x3e\xd5\xde\xb1\x9d\x01"
b"\x00\x80\x3e\xd5\xde\xb1\x9d\x01"
Expand Down Expand Up @@ -281,7 +279,6 @@ def test_parse_message(self):


class TestFileDispositionInformation(object):

DATA = b"\x01"

def test_create_message(self):
Expand Down Expand Up @@ -390,7 +387,6 @@ def test_parse_message(self):


class TestFileFullEaInformation(object):

DATA = b"\x14\x00\x00\x00" b"\x00" b"\x04" b"\x04\x00" b"\x43\x41\x46\xe9\x00" b"\x63\x61\x66\xe9"

def test_create_message(self):
Expand Down Expand Up @@ -420,7 +416,6 @@ def test_parse_message(self):


class TestFileGetEaInformation(object):

DATA = b"\x14\x00\x00\x00" b"\x04" b"\x43\x41\x46\xe9\x00"

def test_create_message(self):
Expand Down Expand Up @@ -608,7 +603,6 @@ def test_parse_message(self):


class TestFileLinkInformation(object):

DATA = (
b"\x01"
b"\x00\x00\x00\x00\x00\x00\x00"
Expand Down Expand Up @@ -673,7 +667,6 @@ def test_parse_message(self):


class TestFileRenameInformation(object):

DATA = (
b"\x01"
b"\x00\x00\x00\x00\x00\x00\x00"
Expand Down Expand Up @@ -746,7 +739,6 @@ def test_parse_message(self):


class TestFileFsObjectInformation(object):

DATA = (
b"\x01\x02\x03\x04\x05\x06\x07\x08"
b"\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
Expand Down Expand Up @@ -780,7 +772,6 @@ def test_parse_message(self):


class TestFileFsVolumeInformation(object):

DATA = (
b"\x00\x80\x3e\xd5\xde\xb1\x9d\x01"
b"\x0a\x00\x00\x00"
Expand Down Expand Up @@ -815,7 +806,6 @@ def test_parse_message(self):


class TestFileFsFullSizeInformation(object):

DATA = (
b"\xa4\x6f\xd6\x01\x00\x00\x00\x00"
b"\x9c\x41\x12\x01\x00\x00\x00\x00"
Expand Down
1 change: 0 additions & 1 deletion tests/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class TestSMB2HeaderAsync(object):

DATA = (
b"\xfe\x53\x4d\x42"
b"\x40\x00"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ def test_parse_message(self):


class TestSMB2QueryInfoRequest(object):

DATA = (
b"\x29\x00"
b"\x01"
Expand Down Expand Up @@ -1164,7 +1163,6 @@ def test_parse_message(self):


class TestOpen(object):

# basic file open tests for each dialect
def test_dialect_2_0_2(self, smb_real):
connection = Connection(uuid.uuid4(), smb_real[2], smb_real[3])
Expand Down
2 changes: 0 additions & 2 deletions tests/test_reparse_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_tag_is_directory(self):


class TestReparseDataBuffer(object):

DATA = b"\x0c\x00\x00\xa0" b"\x04\x00" b"\x00\x00" b"\x01\x02\x03\x04"

def test_create_message(self):
Expand All @@ -50,7 +49,6 @@ def test_parse_message(self):


class TestSymbolicLinkReparseDataBuffer(object):

# Purposefully but the print name before sub name to test that the get_*_name() functions can handle any order.
DATA = (
b"\x08\x00"
Expand Down
1 change: 0 additions & 1 deletion tests/test_smbclient_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,6 @@ def test_scandir_with_cache(smb_real):
smbclient.mkdir(share_path, username=smb_real[0], password=smb_real[1], port=smb_real[3], connection_cache=cache)

try:

dir_path = ntpath.join(share_path, "directory")
smbclient.makedirs(dir_path, exist_ok=True, connection_cache=cache)

Expand Down
2 changes: 0 additions & 2 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ def test_unpack_uuid_field_big_endian(self):


class TestDateTimeField(object):

DATE = datetime(year=1993, month=6, day=11, hour=7, minute=52, second=34, microsecond=34)

class StructureTest(Structure):
Expand Down Expand Up @@ -1489,7 +1488,6 @@ def test_set_invalid(self):


class TestTextField(object):

STRING_VALUE = "Hello World - café"

class StructureTest(Structure):
Expand Down

0 comments on commit ce8e720

Please sign in to comment.