Enable additional ruff rules

In the ruff config file added in #6954 explicitly selecting the ruff
rules to check was missed, resulting in ruff only checking a very small
subset of its available rules. That hasn't been desired, so this is the
first of a series of commits enabling more rules. In this PR all rules
whose violations can be either automatically fixed by ruff or are
trivial to fix manually get enabled. For the follow up PRs it's intended
to focus on one area of rules per PR to gradually improve the Python
code quality.
This commit is contained in:
Dunedan
2024-08-25 06:29:39 +02:00
parent 0ba8ea3429
commit e36c6a31fe
39 changed files with 509 additions and 435 deletions
@@ -1,17 +1,17 @@
# This script provides an overview of the zero_ad wrapper for 0 AD
from os import path
import zero_ad
# First, we will define some helper functions we will use later.
import math
from os import path
import zero_ad
def dist(p1, p2):
return math.sqrt(sum((math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2))))
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2)))
def center(units):
sum_position = map(sum, zip(*map(lambda u: u.position(), units)))
sum_position = map(sum, zip(*(u.position() for u in units)))
return [x / len(units) for x in sum_position]
@@ -33,7 +33,7 @@ game = zero_ad.ZeroAD("http://localhost:6000")
# Load the Arcadia map
samples_dir = path.dirname(path.realpath(__file__))
scenario_config_path = path.join(samples_dir, "arcadia.json")
with open(scenario_config_path, "r") as f:
with open(scenario_config_path, encoding="utf8") as f:
arcadia_config = f.read()
state = game.reset(arcadia_config)