mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
ruff: Enable new lints DTZ, ISC, PIE, PLW, Q, S, SIM.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
17300f196c
commit
2afdb46095
@@ -12,7 +12,7 @@ def setup_path() -> None:
|
||||
activate_this = os.path.join(venv, "bin", "activate_this.py")
|
||||
activate_locals = dict(__file__=activate_this)
|
||||
with open(activate_this) as f:
|
||||
exec(f.read(), activate_locals)
|
||||
exec(f.read(), activate_locals) # noqa: S102
|
||||
# Check that the python version running this function
|
||||
# is same as python version that created the virtualenv.
|
||||
python_version = "python{}.{}".format(*sys.version_info[:2])
|
||||
|
||||
@@ -165,7 +165,7 @@ def su_to_zulip(save_suid: bool = False) -> None:
|
||||
|
||||
|
||||
def make_deploy_path() -> str:
|
||||
timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT)
|
||||
timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT) # noqa: DTZ005
|
||||
return os.path.join(DEPLOYMENTS_DIR, timestamp)
|
||||
|
||||
|
||||
@@ -268,7 +268,9 @@ def get_recent_deployments(threshold_days: int) -> Set[str]:
|
||||
# Returns a list of deployments not older than threshold days
|
||||
# including `/root/zulip` directory if it exists.
|
||||
recent = set()
|
||||
threshold_date = datetime.datetime.now() - datetime.timedelta(days=threshold_days)
|
||||
threshold_date = datetime.datetime.now() - datetime.timedelta( # noqa: DTZ005
|
||||
days=threshold_days
|
||||
)
|
||||
for dir_name in os.listdir(DEPLOYMENTS_DIR):
|
||||
target_dir = os.path.join(DEPLOYMENTS_DIR, dir_name)
|
||||
if not os.path.isdir(target_dir):
|
||||
@@ -278,7 +280,7 @@ def get_recent_deployments(threshold_days: int) -> Set[str]:
|
||||
# Skip things like "lock" that aren't actually a deployment directory
|
||||
continue
|
||||
try:
|
||||
date = datetime.datetime.strptime(dir_name, TIMESTAMP_FORMAT)
|
||||
date = datetime.datetime.strptime(dir_name, TIMESTAMP_FORMAT) # noqa: DTZ007
|
||||
if date >= threshold_date:
|
||||
recent.add(target_dir)
|
||||
except ValueError:
|
||||
@@ -295,7 +297,7 @@ def get_recent_deployments(threshold_days: int) -> Set[str]:
|
||||
def get_threshold_timestamp(threshold_days: int) -> int:
|
||||
# Given number of days, this function returns timestamp corresponding
|
||||
# to the time prior to given number of days.
|
||||
threshold = datetime.datetime.now() - datetime.timedelta(days=threshold_days)
|
||||
threshold = datetime.datetime.now() - datetime.timedelta(days=threshold_days) # noqa: DTZ005
|
||||
threshold_timestamp = int(time.mktime(threshold.utctimetuple()))
|
||||
return threshold_timestamp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user