Skip to content

Commit

Permalink
Fix ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Oliveros committed Jan 21, 2025
1 parent 1b840af commit df59550
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion asyncua/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def get_subscription_revised_params(
and new_keepalive_count != params.RequestedMaxKeepAliveCount
):
_logger.info(
"KeepAliveCount will be updated to %s " "for consistency with RevisedPublishInterval",
"KeepAliveCount will be updated to %s for consistency with RevisedPublishInterval",
new_keepalive_count,
)
modified_params = ua.ModifySubscriptionParameters()
Expand Down
2 changes: 1 addition & 1 deletion asyncua/client/ha/reconciliator.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ async def update_nodes(self, real_map: SubMap, ideal_map: SubMap, targets: Set[s
# in case the previous create_subscription request failed
if not real_sub:
_logger.warning(
"Can't create nodes for %s since underlying " "subscription for %s doesn't exist", url, sub_name
"Can't create nodes for %s since underlying subscription for %s doesn't exist", url, sub_name
)
continue
vs_real = real_map[url][sub_name]
Expand Down
21 changes: 10 additions & 11 deletions asyncua/common/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def create_acknowledge_and_set_limits(self, msg: ua.Hello) -> ua.Acknowledge:
ack.MaxChunkCount = self._select_limit(msg.MaxChunkCount, self.max_chunk_count)
ack.MaxMessageSize = self._select_limit(msg.MaxMessageSize, self.max_message_size)
have_changes = (
self.max_chunk_count != ack.MaxChunkCount or
self.max_recv_buffer != ack.ReceiveBufferSize or
self.max_send_buffer != ack.SendBufferSize or
self.max_message_size != ack.MaxMessageSize
self.max_chunk_count != ack.MaxChunkCount
or self.max_recv_buffer != ack.ReceiveBufferSize
or self.max_send_buffer != ack.SendBufferSize
or self.max_message_size != ack.MaxMessageSize
)
if have_changes:
_logger.info("updating server limits to: %s", self)
Expand All @@ -77,10 +77,10 @@ def create_hello_limits(self, msg: ua.Hello) -> ua.Hello:

def update_client_limits(self, msg: ua.Acknowledge) -> None:
have_changes = (
self.max_chunk_count != msg.MaxChunkCount or
self.max_recv_buffer != msg.ReceiveBufferSize or
self.max_send_buffer != msg.SendBufferSize or
self.max_message_size != msg.MaxMessageSize
self.max_chunk_count != msg.MaxChunkCount
or self.max_recv_buffer != msg.ReceiveBufferSize
or self.max_send_buffer != msg.SendBufferSize
or self.max_message_size != msg.MaxMessageSize
)
if have_changes:
_logger.info("updating client limits to: %s", self)
Expand Down Expand Up @@ -384,8 +384,7 @@ def _check_sym_header(self, security_hdr):
)
if timeout < datetime.now(timezone.utc):
raise ua.UaError(
f"Security token id {security_hdr.TokenId} has timed out "
f"({timeout} < {datetime.now(timezone.utc)})"
f"Security token id {security_hdr.TokenId} has timed out ({timeout} < {datetime.now(timezone.utc)})"
)
return

Expand All @@ -400,7 +399,7 @@ def _check_incoming_chunk(self, chunk):
if chunk.MessageHeader.MessageType != ua.MessageType.SecureOpen:
if chunk.MessageHeader.ChannelId != self.security_token.ChannelId:
raise ua.UaError(
f"Wrong channel id {chunk.MessageHeader.ChannelId}," f" expected {self.security_token.ChannelId}"
f"Wrong channel id {chunk.MessageHeader.ChannelId}, expected {self.security_token.ChannelId}"
)
if self._incoming_parts:
if self._incoming_parts[0].SequenceHeader.RequestId != chunk.SequenceHeader.RequestId:
Expand Down
2 changes: 1 addition & 1 deletion asyncua/common/copy_node_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def _read_and_copy_attrs(node_type: asyncua.Node, struct: Any, addnode: ua
setattr(struct, name, variant.Value)
else:
_logger.warning(
"Instantiate: while copying attributes from node type %s," " attribute %s, statuscode is %s",
"Instantiate: while copying attributes from node type %s, attribute %s, statuscode is %s",
str(node_type),
str(name),
str(results[idx].StatusCode),
Expand Down
2 changes: 1 addition & 1 deletion asyncua/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, data, start_pos=0, size=-1):
self._size = size

def __str__(self):
return f"Buffer(size:{self._size}, data:{self._data[self._cur_pos:self._cur_pos + self._size]})"
return f"Buffer(size:{self._size}, data:{self._data[self._cur_pos : self._cur_pos + self._size]})"

__repr__ = __str__

Expand Down
2 changes: 1 addition & 1 deletion asyncua/common/xmlimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ async def add_datatype(self, obj, no_namespace_migration=False):
is_struct = True
else:
_logger.warning(
"%s has datatypedefinition and path %s" " but we could not find out if this is a struct",
"%s has datatypedefinition and path %s but we could not find out if this is a struct",
obj,
path,
)
Expand Down
4 changes: 2 additions & 2 deletions asyncua/server/history_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def read_node_history(self, node_id, start, end, nb_values):
try:
validate_table_name(table)
async with self._db.execute(
f'SELECT * FROM "{table}" WHERE "SourceTimestamp" BETWEEN ? AND ? ' f'ORDER BY "_Id" {order} LIMIT ?',
f'SELECT * FROM "{table}" WHERE "SourceTimestamp" BETWEEN ? AND ? ORDER BY "_Id" {order} LIMIT ?',
(
start_time,
end_time,
Expand Down Expand Up @@ -294,7 +294,7 @@ def _get_select_clauses(self, source_id, evfilter):
s_clauses.append(name)
except AttributeError:
self.logger.warning(
"Historizing SQL OPC UA Select Clause Warning for node %s," " Clause: %s:", source_id, select_clause
"Historizing SQL OPC UA Select Clause Warning for node %s, Clause: %s:", source_id, select_clause
)
# remove select clauses that the event type doesn't have; SQL will error because the column doesn't exist
clauses = [x for x in s_clauses if x in self._event_fields[source_id]]
Expand Down
3 changes: 1 addition & 2 deletions asyncua/server/internal_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def __init__(

def __str__(self):
return (
f"InternalSession(name:{self.name},"
f" user:{self.user}, id:{self.session_id}, auth_token:{self.auth_token})"
f"InternalSession(name:{self.name}, user:{self.user}, id:{self.session_id}, auth_token:{self.auth_token})"
)

async def get_endpoints(self, params=None, sockname=None):
Expand Down
2 changes: 1 addition & 1 deletion asyncua/server/user_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def add_role(self, certificate_path: Path, user_role: UserRole, name: str,

if name in self._trusted_certificates:
logging.warning(
"certificate with name %s " "attempted to be added multiple times, only the last version will be kept.",
"certificate with name %s attempted to be added multiple times, only the last version will be kept.",
name,
)
self._trusted_certificates[name] = {"certificate": uacrypto.der_from_x509(certificate), "user": user}
Expand Down
2 changes: 1 addition & 1 deletion asyncua/ua/uatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def __init__(self, Text=None, Locale=None):
if self.Text is not None:
if not isinstance(self.Text, str):
raise ValueError(
f'A LocalizedText object takes a string as argument "text"' f"not a {type(self.Text)}, {self.Text}"
f'A LocalizedText object takes a string as argument "text"not a {type(self.Text)}, {self.Text}'
)

if self.Locale is not None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_crypto_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ async def test_security_level_endpoints(srv_crypto_all_certs: Tuple[Server, str]
policy_type = ua.SecurityPolicyType.NoSecurity
else:
policy_type = ua.SecurityPolicyType[
f'{end_point.SecurityPolicyUri.split("#")[1].replace("_", "")}_{end_point.SecurityMode.name}'
f"{end_point.SecurityPolicyUri.split('#')[1].replace('_', '')}_{end_point.SecurityMode.name}"
]
assert end_point.SecurityLevel == SECURITY_POLICY_TYPE_MAP[policy_type][2]

Expand Down

0 comments on commit df59550

Please sign in to comment.