Skip to content

Commit

Permalink
change some coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodenoughPhysicsLab committed Jan 19, 2025
1 parent 61846b1 commit 713e10d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions physicsLab/circuit/elements/artificialCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,10 @@ def set_properties(
@override
def __repr__(self) -> str:
return f"Operational_Amplifier({self._position.x}, {self._position.y}, {self._position.z}, " \
f"elementXYZ={self.is_elementXYZ}, " \
f"gain={self.properties['增益系数']}, " \
f"max_voltage={self.properties['最大电压']}, " \
f"min_voltage={self.properties['最小电压']})"
f"elementXYZ={self.is_elementXYZ}, " \
f"gain={self.properties['增益系数']}, " \
f"max_voltage={self.properties['最大电压']}, " \
f"min_voltage={self.properties['最小电压']})"

@property
def i_neg(self) -> Pin:
Expand Down
4 changes: 2 additions & 2 deletions physicsLab/circuit/elements/basicCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ def set_properties(
@param voltage: 电压
@param internal_resistance: 内阻
'''
if not isinstance(voltage, (int, float, type(None))) or \
not isinstance(internal_resistance, (int, float, type(None))):
if not isinstance(voltage, (int, float, type(None))) \
or not isinstance(internal_resistance, (int, float, type(None))):
raise TypeError

if voltage is not None:
Expand Down
60 changes: 30 additions & 30 deletions physicsLab/web/webutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def __init__(
0: 全部, 1: 系统邮件, 2: 关注和粉丝, 3: 评论和回复, 4: 作品通知, 5: 管理记录
'''

if not isinstance(user, (api.User, type(None))) or \
not isinstance(start_time, (int, float)) or \
not isinstance(end_time, (int, float, type(None))) or \
not isinstance(user_id, (str, type(None))) or \
not isinstance(max_retry, (int, type(None))) or \
not isinstance(category_id, int):
if not isinstance(user, (api.User, type(None))) \
or not isinstance(start_time, (int, float)) \
or not isinstance(end_time, (int, float, type(None))) \
or not isinstance(user_id, (str, type(None))) \
or not isinstance(max_retry, (int, type(None))) \
or not isinstance(category_id, int):
raise TypeError
if category_id not in range(0, 6):
raise ValueError
Expand Down Expand Up @@ -158,12 +158,12 @@ def __init__(
模板可能会被紫兰斋修改, 但消息模板基本都是稳定的
'''

if not isinstance(user, (api.User, type(None))) or \
not isinstance(start_time, (int, float)) or \
not isinstance(end_time, (int, float, type(None))) or \
not isinstance(user_id, (str, type(None))) or \
not isinstance(max_retry, (int, type(None))) or \
not isinstance(get_banned_template, bool):
if not isinstance(user, (api.User, type(None))) \
or not isinstance(start_time, (int, float)) \
or not isinstance(end_time, (int, float, type(None))) \
or not isinstance(user_id, (str, type(None))) \
or not isinstance(max_retry, (int, type(None))) \
or not isinstance(get_banned_template, bool):
raise TypeError

if end_time is None:
Expand Down Expand Up @@ -230,11 +230,11 @@ def __init__(
@param banned_message_callback: 封禁记录回调函数
@return: 封禁记录列表
'''
if not isinstance(user, api.User) or \
not isinstance(user_id, str) or \
not isinstance(start_time, (int, float)) or \
not isinstance(end_time, (int, float, type(None))) or \
maybe_warned_message_callback is not None \
if not isinstance(user, api.User) \
or not isinstance(user_id, str) \
or not isinstance(start_time, (int, float)) \
or not isinstance(end_time, (int, float, type(None))) \
or maybe_warned_message_callback is not None \
and not callable(maybe_warned_message_callback):
raise TypeError
if user.is_anonymous:
Expand Down Expand Up @@ -313,12 +313,12 @@ def __init__(
@param max_retry: 最大重试次数(大于等于0), 为None时不限制重试次数
@param amount: Follower/Following的数量, 为None时api将自动查询
'''
if not isinstance(user, api.User) or \
not isinstance(user_id, str) or \
not isinstance(display_type, str) or \
not isinstance(max_retry, (int, type(None))) or \
not isinstance(amount, (int, type(None))) or \
display_type not in ("Follower", "Following"):
if not isinstance(user, api.User) \
or not isinstance(user_id, str) \
or not isinstance(display_type, str) \
or not isinstance(max_retry, (int, type(None))) \
or not isinstance(amount, (int, type(None))) \
or display_type not in ("Follower", "Following"):
raise TypeError
if max_retry is not None and max_retry < 0:
raise ValueError
Expand Down Expand Up @@ -369,14 +369,14 @@ def __init__(
@param user: 查询者, None为匿名用户
@param max_retry: 最大重试次数(大于等于0), 为None时不限制重试次数
'''
if not isinstance(user_id, str) or \
not isinstance(category, str) or \
not isinstance(size_category, str) or \
not isinstance(user, (api.User, type(None))) or \
not isinstance(max_retry, (int, type(None))):
if not isinstance(user_id, str) \
or not isinstance(category, str) \
or not isinstance(size_category, str) \
or not isinstance(user, (api.User, type(None))) \
or not isinstance(max_retry, (int, type(None))):
raise TypeError
if category not in ("User", "Experiment", "Discussion") or \
size_category not in ("small.round", "thumbnail", "full"):
if category not in ("User", "Experiment", "Discussion") \
or size_category not in ("small.round", "thumbnail", "full"):
raise ValueError

if user is None:
Expand Down

0 comments on commit 713e10d

Please sign in to comment.