Skip to content
Merged
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
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

assert testgres.__path__ is not None
assert len(testgres.__path__) == 1
assert type(testgres.__path__[0] == str) # noqa: E721
assert type(testgres.__path__[0]) is str
p = os.path.dirname(testgres.__path__[0])
assert type(p) == str # noqa: E721
assert type(p) is str
sys.path.insert(0, os.path.abspath(p))

# -- Project information -----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def spawn_primary(self, name=None, destroy=True):
node = NodeClass(name=name, base_dir=base_dir, conn_params=self.original_node.os_ops.conn_params)

assert node is not None
assert type(node) == self.original_node.__class__ # noqa: E721
assert type(node) is self.original_node.__class__

with clean_on_error(node) as node:
# Set a new port
Expand Down
2 changes: 1 addition & 1 deletion src/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def cached_initdb(data_dir, logfile=None, params=None, os_ops: OsOperations = No

def make_utility_path(name):
assert name is not None
assert type(name) == str # noqa: E721
assert type(name) is str

if bin_path:
return os_ops.build_path(bin_path, name)
Expand Down
42 changes: 21 additions & 21 deletions src/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def __init__(
self,
message: typing.Optional[str] = None,
):
assert message is None or type(message) == str # noqa: E721
assert message is None or type(message) is str
super().__init__(message)
self._message = message
return

@property
def message(self) -> str:
assert self._message is None or type(self._message) == str # noqa: E721
assert self._message is None or type(self._message) is str
if self._message is None:
return ""
return self._message
Expand Down Expand Up @@ -53,8 +53,8 @@ def __init__(
message: typing.Optional[str] = None,
query: typing.Optional[str] = None
):
assert message is None or type(message) == str # noqa: E721
assert query is None or type(query) == str # noqa: E721
assert message is None or type(message) is str
assert query is None or type(query) is str

super().__init__(message)

Expand All @@ -64,8 +64,8 @@ def __init__(

@property
def message(self) -> str:
assert self._description is None or type(self._description) == str # noqa: E721
assert self._query is None or type(self._query) == str # noqa: E721
assert self._description is None or type(self._description) is str
assert self._query is None or type(self._query) is str

msg = []

Expand All @@ -76,17 +76,17 @@ def message(self) -> str:
msg.append(u'Query: {}'.format(self._query))

r = six.text_type('\n').join(msg)
assert type(r) == str # noqa: E721
assert type(r) is str
return r

@property
def description(self) -> typing.Optional[str]:
assert self._description is None or type(self._description) == str # noqa: E721
assert self._description is None or type(self._description) is str
return self._description

@property
def query(self) -> typing.Optional[str]:
assert self._query is None or type(self._query) == str # noqa: E721
assert self._query is None or type(self._query) is str
return self._query

def __repr__(self) -> str:
Expand Down Expand Up @@ -114,8 +114,8 @@ def __init__(
message: typing.Optional[str] = None,
query: typing.Optional[str] = None
):
assert message is None or type(message) == str # noqa: E721
assert query is None or type(query) == str # noqa: E721
assert message is None or type(message) is str
assert query is None or type(query) is str

super().__init__(message, query)
return
Expand All @@ -133,14 +133,14 @@ def __init__(
self,
message: typing.Optional[str] = None,
):
assert message is None or type(message) == str # noqa: E721
assert message is None or type(message) is str
super().__init__(message)
self._message = message
return

@property
def message(self) -> str:
assert self._message is None or type(self._message) == str # noqa: E721
assert self._message is None or type(self._message) is str
if self._message is None:
return ""
return self._message
Expand Down Expand Up @@ -171,7 +171,7 @@ def __init__(
message: typing.Optional[str] = None,
files: typing.Optional[typing.Iterable] = None
):
assert message is None or type(message) == str # noqa: E721
assert message is None or type(message) is str
assert files is None or isinstance(files, typing.Iterable)

super().__init__(message)
Expand All @@ -182,7 +182,7 @@ def __init__(

@property
def message(self) -> str:
assert self._description is None or type(self._description) == str # noqa: E721
assert self._description is None or type(self._description) is str
assert self._files is None or isinstance(self._files, typing.Iterable)

msg = []
Expand All @@ -191,15 +191,15 @@ def message(self) -> str:
msg.append(self._description)

for f, lines in self._files or []:
assert type(f) == str # noqa: E721
assert type(f) is str
assert type(lines) in [str, bytes] # noqa: E721
msg.append(u'{}\n----\n{}\n'.format(f, lines))

return six.text_type('\n').join(msg)

@property
def description(self) -> typing.Optional[str]:
assert self._description is None or type(self._description) == str # noqa: E721
assert self._description is None or type(self._description) is str
return self._description

@property
Expand Down Expand Up @@ -233,14 +233,14 @@ def __init__(
self,
message: typing.Optional[str] = None,
):
assert message is None or type(message) == str # noqa: E721
assert message is None or type(message) is str
super().__init__(message)
self._message = message
return

@property
def message(self) -> str:
assert self._message is None or type(self._message) == str # noqa: E721
assert self._message is None or type(self._message) is str
if self._message is None:
return ""
return self._message
Expand Down Expand Up @@ -268,14 +268,14 @@ def __init__(
self,
message: typing.Optional[str] = None,
):
assert message is None or type(message) == str # noqa: E721
assert message is None or type(message) is str
super().__init__(message)
self._message = message
return

@property
def message(self) -> str:
assert self._message is None or type(self._message) == str # noqa: E721
assert self._message is None or type(self._message) is str
if self._message is None:
return ""
return self._message
Expand Down
8 changes: 4 additions & 4 deletions src/impl/internal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@


def send_log(level: int, msg: str) -> None:
assert type(level) == int # noqa: E721
assert type(msg) == str # noqa: E721
assert type(level) is int
assert type(msg) is str

return logging.log(level, "[testgres] " + msg)


def send_log_info(msg: str) -> None:
assert type(msg) == str # noqa: E721
assert type(msg) is str

return send_log(logging.INFO, msg)


def send_log_debug(msg: str) -> None:
assert type(msg) == str # noqa: E721
assert type(msg) is str

return send_log(logging.DEBUG, msg)
10 changes: 5 additions & 5 deletions src/impl/platforms/internal_platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def __init__(
code: InternalPlatformUtils.FindPostmasterResultCode,
pid: typing.Optional[int]
):
assert type(code) == InternalPlatformUtils.FindPostmasterResultCode # noqa: E721
assert pid is None or type(pid) == int # noqa: E721
assert type(code) is InternalPlatformUtils.FindPostmasterResultCode
assert pid is None or type(pid) is int
self.code = code
self.pid = pid
return

@staticmethod
def create_ok(pid: int) -> InternalPlatformUtils.FindPostmasterResult:
assert type(pid) == int # noqa: E721
assert type(pid) is int
return __class__(InternalPlatformUtils.FindPostmasterResultCode.ok, pid)

@staticmethod
Expand All @@ -57,6 +57,6 @@ def FindPostmaster(
data_dir: str
) -> FindPostmasterResult:
assert isinstance(os_ops, OsOperations)
assert type(bin_dir) == str # noqa: E721
assert type(data_dir) == str # noqa: E721
assert type(bin_dir) is str
assert type(data_dir) is str
raise NotImplementedError("InternalPlatformUtils::FindPostmaster is not implemented.")
2 changes: 1 addition & 1 deletion src/impl/platforms/internal_platform_utils_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create_internal_platform_utils(
assert isinstance(os_ops, OsOperations)

platform_name = os_ops.get_platform()
assert type(platform_name) == str # noqa: E721
assert type(platform_name) is str

if platform_name == "linux":
from .linux import internal_platform_utils as x
Expand Down
28 changes: 14 additions & 14 deletions src/impl/platforms/linux/internal_platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ def FindPostmaster(
data_dir: str
) -> InternalPlatformUtils.FindPostmasterResult:
assert isinstance(os_ops, OsOperations)
assert type(bin_dir) == str # noqa: E721
assert type(data_dir) == str # noqa: E721
assert type(__class__.C_BASH_EXE) == str # noqa: E721
assert type(__class__.sm_exec_env) == dict # noqa: E721
assert type(bin_dir) is str
assert type(data_dir) is str
assert type(__class__.C_BASH_EXE) is str
assert type(__class__.sm_exec_env) is dict
assert len(__class__.C_BASH_EXE) > 0
assert len(bin_dir) > 0
assert len(data_dir) > 0

pg_path_e = re.escape(os_ops.build_path(bin_dir, "postgres"))
data_dir_e = re.escape(data_dir)

assert type(pg_path_e) == str # noqa: E721
assert type(data_dir_e) == str # noqa: E721
assert type(pg_path_e) is str
assert type(data_dir_e) is str

regexp = r"^\s*[0-9]+\s+" + pg_path_e + r"(\s+.*)?\s+\-[D]\s+" + data_dir_e + r"(\s+.*)?"

Expand All @@ -55,14 +55,14 @@ def FindPostmaster(
exec_env=__class__.sm_exec_env,
)

assert type(output_b) == bytes # noqa: E721
assert type(error_b) == bytes # noqa: E721
assert type(output_b) is bytes
assert type(error_b) is bytes

output = output_b.decode("utf-8")
error = error_b.decode("utf-8")

assert type(output) == str # noqa: E721
assert type(error) == str # noqa: E721
assert type(output) is str
assert type(error) is str

if exit_status == 1:
return __class__.FindPostmasterResult.create_not_found()
Expand All @@ -78,7 +78,7 @@ def FindPostmaster(
)

lines = output.splitlines()
assert type(lines) == list # noqa: E721
assert type(lines) is list

if len(lines) == 0:
return __class__.FindPostmasterResult.create_not_found()
Expand All @@ -88,15 +88,15 @@ def FindPostmaster(
msgs.append("Many processes like a postmaster are found: {}.".format(len(lines)))

for i in range(len(lines)):
assert type(lines[i]) == str # noqa: E721
assert type(lines[i]) is str
lines.append("[{}] '{}'".format(i, lines[i]))
continue

internal_utils.send_log_debug("\n".join(lines))
return __class__.FindPostmasterResult.create_many_processes()

def is_space_or_tab(ch) -> bool:
assert type(ch) == str # noqa: E721
assert type(ch) is str
return ch == " " or ch == "\t"

line = lines[0]
Expand All @@ -115,6 +115,6 @@ def is_space_or_tab(ch) -> bool:
return __class__.FindPostmasterResult.create_has_problems()

pid = int(line[start:pos])
assert type(pid) == int # noqa: E721
assert type(pid) is int

return __class__.FindPostmasterResult.create_ok(pid)
4 changes: 2 additions & 2 deletions src/impl/platforms/win32/internal_platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def FindPostmaster(
data_dir: str
) -> InternalPlatformUtils.FindPostmasterResult:
assert isinstance(os_ops, OsOperations)
assert type(bin_dir) == str # noqa: E721
assert type(data_dir) == str # noqa: E721
assert type(bin_dir) is str
assert type(data_dir) is str
return __class__.FindPostmasterResult.create_not_implemented()
Loading