Skip to content

Commit f8dc20d

Browse files
Fix pylint and getattr TypeErrors
1 parent 75ca93f commit f8dc20d

13 files changed

Lines changed: 484 additions & 30 deletions

File tree

.claude/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(.venv/Scripts/python.exe -c \"import rocketserializer; print\\(''Import OK''\\)\")",
5+
"Bash(java -version)"
6+
]
7+
}
8+
}

extract_bugs.txt

Whitespace-only changes.

high_severity.md

Lines changed: 376 additions & 0 deletions
Large diffs are not rendered by default.

high_severity.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
4: description="Advanced 6-DOF trajectory simulation for High-Power Rocketry."
2+
The user changed setting `Model Selection` from None to Gemini 3.1 Pro (High). No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.
3+
The user changed setting `Model Selection` from None to Gemini 3.1 Pro (High). No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.
4+
106: ### High Priority
5+
"description": "Next generation High-Power Rocketry 6-DOF Trajectory Simulation",
6+
113: "description": "Next generation High-Power Rocketry 6-DOF Trajectory Simulation",
7+
250: "description": "Next generation High-Power Rocketry 6-DOF Trajectory Simulation",
8+
546: "description": "Next generation High-Power Rocketry 6-DOF Trajectory Simulation",
9+
700: "description": "Next generation High-Power Rocketry 6-DOF Trajectory Simulation",
10+
274: <meta name="description" content="Next generation High-Power Rocketry 6-DOF Trajectory Simulation - ENH: Add custom exceptions and unstable rocket warning (#285) by Matanski � Pull Request #970 � RocketPy-Team/RocketPy">

rocketserializer/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def ork2json(filepath, output=None, ork_jar=None, encoding="utf-8", verbose=Fals
217217
@click.option("--ork_jar", type=str, default=None, required=False)
218218
@click.option("--encoding", type=str, default="utf-8", required=False)
219219
@click.option("--verbose", is_flag=True, default=False, help="Enable verbose logging")
220-
def ork2notebook(filepath, output, ork_jar=None, encoding="utf-8", verbose=False):
220+
def ork2notebook(filepath, output, ork_jar=None, encoding="utf-8", verbose=False): # pylint: disable=unused-argument
221221
"""Generates a .ipynb file from the .ork file.
222222
223223
Notes

rocketserializer/components/fins.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ def get_element_by_name(name):
7070
logger.info("Span retrieved: %f", span)
7171

7272
sweep_length = (
73-
float(getattr(fin.find("sweeplength"), "text", "0")) if fin.find("sweeplength") else None
73+
float(getattr(fin.find("sweeplength"), "text", "0"))
74+
if fin.find("sweeplength")
75+
else None
7476
)
7577
sweep_angle = (
76-
float(getattr(fin.find("sweepangle"), "text", "0")) if fin.find("sweepangle") else None
78+
float(getattr(fin.find("sweepangle"), "text", "0"))
79+
if fin.find("sweepangle")
80+
else None
7781
)
7882
logger.info(
7983
"Sweep length and angle retrieved: %s, %s", sweep_length, sweep_angle

rocketserializer/components/id.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,31 @@ def search_id_info(bs, filepath):
2424
"filepath".
2525
"""
2626
settings = {}
27-
settings["rocket_name"] = bs.find(getattr("rocket").find("name"), "text", "")
28-
logger.info("Collected the rocket name: '%s'", settings["rocket_name"])
29-
30-
try:
31-
settings["comment"] = bs.find(getattr("rocket").find("comment"), "text", "").replace("\n", "")
32-
logger.info("Collected the comment saved in the file: %s", settings["comment"])
33-
except AttributeError:
34-
logger.warning("No auxiliary comment was found in the file.")
27+
rocket_tag = bs.find("rocket")
28+
if rocket_tag:
29+
settings["rocket_name"] = getattr(rocket_tag.find("name"), "text", "")
30+
logger.info("Collected the rocket name: '%s'", settings["rocket_name"])
31+
32+
comment_tag = rocket_tag.find("comment")
33+
if comment_tag and comment_tag.text:
34+
settings["comment"] = comment_tag.text.replace("\n", "")
35+
logger.info(
36+
"Collected the comment saved in the file: %s", settings["comment"]
37+
)
38+
else:
39+
logger.warning("No auxiliary comment was found in the file.")
40+
settings["comment"] = None
41+
42+
designer_tag = rocket_tag.find("designer")
43+
if designer_tag and designer_tag.text:
44+
settings["designer"] = designer_tag.text
45+
logger.info("Collected the designer name: %s", settings["designer"])
46+
else:
47+
logger.warning("No designer name was found in the file.")
48+
settings["designer"] = None
49+
else:
50+
settings["rocket_name"] = ""
3551
settings["comment"] = None
36-
try:
37-
settings["designer"] = bs.find(getattr("rocket").find("designer"), "text", "")
38-
logger.info("Collected the designer name: %s", settings["designer"])
39-
except AttributeError:
40-
logger.warning("No designer name was found in the file.")
4152
settings["designer"] = None
4253
# settings["ork_version"] = bs.attrs["creator"]
4354
settings["filepath"] = Path(filepath).as_posix()

rocketserializer/components/motor.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ def search_motor(bs, datapoints, data_labels):
3939
settings = {}
4040

4141
# retrieve motor geometry
42-
motor_length = float(bs.find(getattr("motormount").find("length"), "text", ""))
43-
motor_radius = float(bs.find(getattr("motormount").find("diameter"), "text", "")) / 2
42+
motormount = bs.find("motormount")
43+
if motormount is not None:
44+
motor_length = float(getattr(motormount.find("length"), "text", "") or "0")
45+
diam = getattr(motormount.find("diameter"), "text", "") or "0"
46+
motor_radius = float(diam) / 2
47+
else:
48+
motor_length = 0.0
49+
motor_radius = 0.0
4450
logger.info("Collected motor geometry: motor length and motor radius.")
4551

4652
# get motor mass properties
@@ -183,7 +189,9 @@ def __get_motor_mass(datapoints, data_labels):
183189
prop_mass_vector = list(prop_mass_vector)
184190
logger.info("The motor dry mass is %.3f kg.", motor_dry_mass)
185191
else:
186-
raise ValueError("Neither 'Propellant mass' nor 'Motor mass' found in data_labels.")
192+
raise ValueError(
193+
"Neither 'Propellant mass' nor 'Motor mass' found in data_labels."
194+
)
187195

188196
normalize = np.array(prop_mass_vector)
189197
normalize = normalize - normalize[np.argmin(normalize)]

rocketserializer/components/nose_cone.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def search_nosecone(bs, elements=None, rocket_radius=None, just_radius=False):
3131
if not nosecone:
3232
nosecones = list(
3333
filter(
34-
lambda x: getattr(x.find("name"), "text", "") == "Nosecone", bs.find_all("transition")
34+
lambda x: getattr(x.find("name"), "text", "") == "Nosecone",
35+
bs.find_all("transition"),
3536
)
3637
)
3738
if len(nosecones) == 0:

rocketserializer/components/parachute.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def search_parachutes(bs):
3333
name = getattr(chute.find("name"), "text", "")
3434

3535
# parachute settings
36-
cd = "auto" if "auto" in getattr(chute.find("cd"), "text", "") else float(getattr(chute.find("cd"), "text", "0"))
36+
cd = (
37+
"auto"
38+
if "auto" in getattr(chute.find("cd"), "text", "")
39+
else float(getattr(chute.find("cd"), "text", "0"))
40+
)
3741
cd = search_cd_chute_if_auto(chute) if cd == "auto" else cd
3842
area = np.pi * float(getattr(chute.find("diameter"), "text", "0")) ** 2 / 4
3943
cds = cd * area
@@ -70,9 +74,11 @@ def search_parachutes(bs):
7074

7175

7276
def search_cd_chute_if_auto(bs):
73-
# if the parachute cd is set to "auto", OpenRocket defaults to 0.75 (flat) or 1.5 (dome).
74-
# Since we cannot easily deduce the type, 0.75 is the most common standard parachute CD in OR.
77+
# if the parachute cd is set to "auto", OpenRocket defaults to 0.75 (flat)
78+
# or 1.5 (dome). Since we cannot easily deduce the type, 0.75 is the
79+
# most common standard parachute CD in OR.
7580
logger.warning(
76-
"cd auto: the cd is set to 0.75 for parachute %s", getattr(bs.find("name"), "text", "Unknown")
81+
"cd auto: the cd is set to 0.75 for parachute %s",
82+
getattr(bs.find("name"), "text", "Unknown"),
7783
)
7884
return 0.75

0 commit comments

Comments
 (0)