Skip to content

Commit

Permalink
Start enforcing Ruff rule ANN201 in modeling
Browse files Browse the repository at this point in the history
The rule checks for public functions without a return type annotation.
`modeling` was the last sub-package where this rule was not enforced.
Note that Ruff is configured to check this rule only for functions that
already have a type annotation in their signature.
  • Loading branch information
eerovaher committed Mar 20, 2024
1 parent 1ff8068 commit 8aabbcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ lint.unfixable = [
]
"astropy/logger.py" = ["C408", "RET505"]
"astropy/modeling/*" = [
"ANN201", # Public function without return type annotation
"PLR0911", # too-many-return-statements
"RET505", # superfluous-else-return
"RET506", # superfluous-else-raise
Expand Down
10 changes: 6 additions & 4 deletions astropy/modeling/bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ def __getitem__(self, key):
else:
return self._intervals[self._get_index(key)]

def bounding_box(self, order: str | None = None):
def bounding_box(
self, order: str | None = None
) -> tuple[float, float] | tuple[tuple[float, float], ...]:
"""
Return the old tuple of tuples representation of the bounding_box
order='C' corresponds to the old bounding_box ordering
Expand Down Expand Up @@ -817,7 +819,7 @@ def validate(

return new

def fix_inputs(self, model, fixed_inputs: dict, _keep_ignored=False):
def fix_inputs(self, model, fixed_inputs: dict, _keep_ignored=False) -> Self:
"""
Fix the bounding_box for a `fix_inputs` compound model.
Expand Down Expand Up @@ -848,7 +850,7 @@ def fix_inputs(self, model, fixed_inputs: dict, _keep_ignored=False):
def dimension(self):
return len(self)

def domain(self, resolution, order: str | None = None):
def domain(self, resolution, order: str | None = None) -> list[np.ndarray]:
inputs = self._model.inputs
order = self._get_order(order)
if order == "C":
Expand Down Expand Up @@ -1606,7 +1608,7 @@ def _fix_input_bbox_arg(self, argument, value):
self.selector_args.add_ignore(self._model, argument),
)

def fix_inputs(self, model, fixed_inputs: dict):
def fix_inputs(self, model, fixed_inputs: dict) -> Self:
"""
Fix the bounding_box for a `fix_inputs` compound model.
Expand Down

0 comments on commit 8aabbcc

Please sign in to comment.