Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8133cd0
Separate ruff rules from pyproject toml file and upgrade pre commit
Feb 25, 2025
f446c6d
Separate ruff rules from pyproject toml file and upgrade pre commit
Feb 25, 2025
4dd958b
Merge remote-tracking branch 'origin/ruff_newrules' into ruff_newrule…
Feb 25, 2025
bde9c05
Add UP RET FBT FA PTH ruff linting rules
Mar 10, 2025
fedffa9
Better commenting on hard to understand code
enricostragiotti Apr 2, 2025
3e854ad
Fixed CS25 errors, no more breaking changes
enricostragiotti Apr 2, 2025
9d4b868
Completely reworking and reverting the proposed _is_shape_by_conn method
enricostragiotti Apr 3, 2025
4e7d601
Merge pull request #609 from fast-aircraft-design/ruff_newrules_UP_RE…
enricostragiotti Apr 17, 2025
a74985d
Merge remote-tracking branch 'origin/master' into ruff_newrules + com…
enricostragiotti Jun 11, 2025
6e14aaa
Ruff dependency update
enricostragiotti Jun 11, 2025
3286df7
[skip ci] added new batch of rules
enricostragiotti Jun 19, 2025
d163dcf
Implemented the fix for the new rules. Tests pass in local
enricostragiotti Jul 4, 2025
61a424b
removed old commented code
enricostragiotti Nov 12, 2025
0fd852f
updated the noqa comments
enricostragiotti Nov 12, 2025
3a0d494
rollback variable test eq
enricostragiotti Nov 12, 2025
0586805
rollback wrong commit on ipynb metadata
enricostragiotti Nov 12, 2025
74f3e44
reimplemented default_val
enricostragiotti Nov 12, 2025
63d9416
Added BLE set rules
enricostragiotti Nov 13, 2025
6df26c8
review fixing
enricostragiotti Nov 13, 2025
94e2550
added KeyError in FASTConfigurationBadOpenMDAOInstructionError in om …
enricostragiotti Nov 13, 2025
150fc16
Merge pull request #634 from fast-aircraft-design/ruff_lining_IT2
enricostragiotti Nov 13, 2025
c02f834
Ruff dependency update
enricostragiotti Nov 13, 2025
413fb6e
Merge remote-tracking branch 'origin/master' into ruff_newrules
enricostragiotti Nov 13, 2025
484d903
linted origin/master, ready to merge in master
enricostragiotti Nov 13, 2025
67121b7
[skip ci] Merge remote-tracking branch 'origin/master' into ruff_newr…
enricostragiotti Nov 18, 2025
35434a5
linting master before merge
enricostragiotti Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: ruff
name: ruff
description: "Run 'ruff' for extremely fast Python linting"
entry: ruff check --force-exclude
entry: poetry run ruff check --force-exclude
language: python
types_or: [ python, pyi, jupyter ]
args: [ ]
Expand All @@ -26,7 +26,7 @@ repos:
- id: ruff-format
name: ruff-format
description: "Run 'ruff format' for extremely fast Python formatting"
entry: ruff format --force-exclude
entry: poetry run ruff format --force-exclude
language: python
types_or: [ python, pyi, jupyter ]
args: [ ]
Expand Down
37 changes: 19 additions & 18 deletions devutils/rename_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import fileinput
import os
import os.path as pth
import re
from pathlib import Path

import numpy as np

Expand All @@ -33,10 +33,10 @@
from fastoad.io.xml.variable_io_standard import BasicVarXpathTranslator
from tests import root_folder_path

SRC_PATH = pth.join(root_folder_path, "src")
TEST_PATH = pth.join(root_folder_path, "tests")
NOTEBOOK_PATH = pth.join(root_folder_path, "notebooks")
VAR_NAME_FILE = pth.join(pth.dirname(__file__), "rename_vars.txt")
SRC_PATH = Path(root_folder_path) / "src"
TEST_PATH = Path(root_folder_path) / "tests"
NOTEBOOK_PATH = Path(root_folder_path) / "notebooks"
VAR_NAME_FILE = Path(__file__).parent / "rename_vars.txt"


def build_translator(var_names_match: np.ndarray) -> VarXpathTranslator:
Expand Down Expand Up @@ -64,30 +64,31 @@ def convert_xml(file_path: str, translator: VarXpathTranslator):
:param translator:
"""
reader = VariableIO(file_path, formatter=VariableXmlBaseFormatter(translator))
vars = reader.read()
VariableIO(file_path).write(vars)
variables = reader.read()
VariableIO(file_path).write(variables)


def replace_var_names(file_path, var_names_match):
"""
Modifies provided text file by modifying old OpenMDAO variable names
to new ones.

:param file_path:
:param var_names_match:
:param file_path: Path to the file to be modified.
:param var_names_match: List of (old_name, new_name) tuples.
"""
(_, ext) = pth.splitext(file_path)
ext = Path(file_path).suffix # Extract file extension using pathlib

with fileinput.FileInput(file_path, inplace=True) as file:
for line in file:
modified_line = line
for old_name, new_name in var_names_match:
if ext == ".py":
# Python file: replacement is done only between (double) quotes
regex = r"""(?<=['"])\b%s\b(?=['"])""" % old_name
regex = rf"""(?<=['"])\b{old_name}\b(?=['"])"""
else:
# other files: just ensuring it is not part of a larger variable name
# by avoiding having ':' before or after.
regex = r"(?<!:)\b%s\b(?!:)" % old_name
regex = rf"(?<!:)\b{old_name}\b(?!:)"
modified_line = re.sub(regex, new_name, modified_line)
print(modified_line, end="")

Expand Down Expand Up @@ -132,24 +133,24 @@ def get_xpath(self, var_name: str) -> str:
"src/fastoad/notebooks/tutorial/data/CeRAS01_baseline.xml",
]
for xml_file_path in file_list:
print("processing %s" % xml_file_path)
convert_xml(pth.join(root_folder_path, xml_file_path), old_new_translator)
print(f"processing {xml_file_path}")
convert_xml(root_folder_path / xml_file_path, old_new_translator)

# replace var names
for root_path in [SRC_PATH, TEST_PATH, NOTEBOOK_PATH]:
for dir_path, dir_names, file_names in os.walk(root_path):
for filename in file_names:
_, ext = pth.splitext(filename)
ext = Path(filename).suffix
if ext not in [
".xml",
".pyc",
".exe",
".png",
"",
]: # avoid processing useless files
file_path = pth.join(dir_path, filename)
print("processing %s" % file_path)
file_path = dir_path / filename
print(f"processing {file_path}")
try:
replace_var_names(file_path, old_new_names)
except UnicodeDecodeError:
print("SKIPPED %s" % file_path)
print(f"SKIPPED {file_path}")
19 changes: 10 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys
from os import environ
from pathlib import Path

from sphinx.ext import apidoc

Expand All @@ -29,10 +29,10 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.

# For custom directives
sys.path.insert(0, os.path.abspath("./directives"))
sys.path.insert(0, str(Path("./directives").resolve()))

# For autodoc... and custom directives
sys.path.insert(0, os.path.abspath("../src"))
sys.path.insert(0, str(Path("../src").resolve()))

# Overload apidoc options, to add "inherited-members" (which was deactivated because of a bug
# in earlier sphinx releases)
Expand All @@ -41,11 +41,12 @@

# -- Run sphinx-apidoc ------------------------------------------------------
def run_apidoc(_):
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
cur_dir = os.path.abspath(os.path.dirname(__file__))
output_dir = os.path.join(cur_dir, "api")
module = os.path.join(cur_dir, "..", "src", "fastoad")
apidoc.main(["-d", "1", "-e", "-o", output_dir, module, "--force"])
sys.path.append(str(Path(__file__).parent.parent)) # Append project root
cur_dir = Path(__file__).parent.resolve()
output_dir = cur_dir / "api"
module = cur_dir.parent / "src" / "fastoad"

apidoc.main(["-d", "1", "-e", "-o", str(output_dir), str(module), "--force"])


def setup(app):
Expand All @@ -54,7 +55,7 @@ def setup(app):

# -- Project information -----------------------------------------------------
project = "FAST-OAD"
copyright = "2025, ONERA & ISAE-SUPAERO"
copyright = "2025, ONERA & ISAE-SUPAERO" # noqa: A001 copyright is a keyword for the sphinx setup

# -- General configuration ---------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions docs/directives/segment_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from abc import ABC, abstractmethod
from dataclasses import fields
from typing import List, Tuple

from docutils import nodes
from sphinx.util.docutils import SphinxDirective
Expand All @@ -39,7 +38,7 @@ class AbstractLinkList(SphinxDirective, ABC):
header_text = None

@abstractmethod
def get_text_and_targets(self) -> List[Tuple[str, str]]:
def get_text_and_targets(self) -> list[tuple[str, str]]:
"""
:return: a list of tuples for future hyperlinks (displayed text, rst target)
"""
Expand Down Expand Up @@ -97,7 +96,7 @@ def get_text_and_targets(self):
attribute_name = self.content[0].strip()

class_dict = RegisterSegment.get_classes()
segment_keywords = sorted(list(class_dict))
segment_keywords = sorted(class_dict)

valid_keywords = [
keyword for keyword in segment_keywords if hasattr(class_dict[keyword], attribute_name)
Expand Down Expand Up @@ -154,8 +153,9 @@ def check_targets(app, doctree):
continue

child_nodes = _generate_hyperlink_list(app, doctree, target_list)

directive_location += child_nodes
# Reassigning directive_location by appending children directly to the docutils node.
# This is intentional and required to inject generated content into the document tree.
directive_location += child_nodes # noqa: PLW2901


def _generate_hyperlink_list(app, doctree, target_list):
Expand Down
Loading
Loading