diff --git a/.ruff.toml b/.ruff.toml index f99a75e527c..f986e2a2be0 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -179,7 +179,6 @@ ignore = [ "RET505", # superfluous-else-return "RET506", # superfluous-else-raise "RET507", # superfluous-else-continue - "RET508", # superfluous-else-break # flake8-raise (RSE) "RSE102", # unnecessary-paren-on-raise-exception diff --git a/astropy/io/ascii/sextractor.py b/astropy/io/ascii/sextractor.py index 4843ec65de1..dde88ba5a5e 100644 --- a/astropy/io/ascii/sextractor.py +++ b/astropy/io/ascii/sextractor.py @@ -53,15 +53,16 @@ def get_cols(self, lines): if not line.startswith("#"): dataline = line # save for later to infer the actual number of columns break # End of header lines - else: - match = re_name_def.search(line) - if match: - colnumber = int(match.group("colnumber")) - colname = match.group("colname") - coldescr = match.group("coldescr") - # If no units are given, colunit = None - colunit = match.group("colunit") - columns[colnumber] = (colname, coldescr, colunit) + + match = re_name_def.search(line) + if match: + colnumber = int(match.group("colnumber")) + colname = match.group("colname") + coldescr = match.group("coldescr") + # If no units are given, colunit = None + colunit = match.group("colunit") + columns[colnumber] = (colname, coldescr, colunit) + # Handle skipped column numbers colnumbers = sorted(columns) # Handle the case where the last column is array-like by append a pseudo column diff --git a/astropy/io/fits/hdu/image.py b/astropy/io/fits/hdu/image.py index c1f9a326f66..1ba9f2d151d 100644 --- a/astropy/io/fits/hdu/image.py +++ b/astropy/io/fits/hdu/image.py @@ -1050,7 +1050,8 @@ def _getdata(self, keys): if isinstance(key, slice): ks = range(*key.indices(axis)) break - elif isiterable(key): + + if isiterable(key): # Handle both integer and boolean arrays. ks = np.arange(axis, dtype=int)[key] break diff --git a/astropy/io/votable/tree.py b/astropy/io/votable/tree.py index c7ac51a8c29..b8ec93f7cfb 100644 --- a/astropy/io/votable/tree.py +++ b/astropy/io/votable/tree.py @@ -2740,39 +2740,38 @@ def parse(self, iterator, config): if (not skip_table) and (len(fields) > 0): for start, tag, data, pos in iterator: - if start: - if tag == "TABLEDATA": - warn_unknown_attrs("TABLEDATA", data.keys(), config, pos) - self.array = self._parse_tabledata( - iterator, colnumbers, fields, config - ) - break - elif tag == "BINARY": - warn_unknown_attrs("BINARY", data.keys(), config, pos) - self.array = self._parse_binary( - 1, iterator, colnumbers, fields, config, pos - ) - break - elif tag == "BINARY2": - if not config["version_1_3_or_later"]: - warn_or_raise(W52, W52, config["version"], config, pos) - self.array = self._parse_binary( - 2, iterator, colnumbers, fields, config, pos - ) - break - elif tag == "FITS": - warn_unknown_attrs("FITS", data.keys(), config, pos, ["extnum"]) - try: - extnum = int(data.get("extnum", 0)) - if extnum < 0: - raise ValueError("'extnum' cannot be negative.") - except ValueError: - vo_raise(E17, (), config, pos) - self.array = self._parse_fits(iterator, extnum, config) - break - else: - warn_or_raise(W37, W37, tag, config, pos) - break + if not start: + continue + + if tag == "TABLEDATA": + warn_unknown_attrs("TABLEDATA", data.keys(), config, pos) + self.array = self._parse_tabledata( + iterator, colnumbers, fields, config + ) + elif tag == "BINARY": + warn_unknown_attrs("BINARY", data.keys(), config, pos) + self.array = self._parse_binary( + 1, iterator, colnumbers, fields, config, pos + ) + elif tag == "BINARY2": + if not config["version_1_3_or_later"]: + warn_or_raise(W52, W52, config["version"], config, pos) + self.array = self._parse_binary( + 2, iterator, colnumbers, fields, config, pos + ) + elif tag == "FITS": + warn_unknown_attrs("FITS", data.keys(), config, pos, ["extnum"]) + try: + extnum = int(data.get("extnum", 0)) + if extnum < 0: + raise ValueError("'extnum' cannot be negative.") + except ValueError: + vo_raise(E17, (), config, pos) + self.array = self._parse_fits(iterator, extnum, config) + else: + warn_or_raise(W37, W37, tag, config, pos) + + break for start, tag, data, pos in iterator: if not start and tag == "DATA": diff --git a/astropy/table/pprint.py b/astropy/table/pprint.py index 6213cae2460..df45898f6bc 100644 --- a/astropy/table/pprint.py +++ b/astropy/table/pprint.py @@ -809,7 +809,8 @@ def _more_tabcol( if key.lower() == "q": break - elif key == " " or key == "f": + + if key == " " or key == "f": i0 += delta_lines elif key == "b": i0 = i0 - delta_lines diff --git a/astropy/units/core.py b/astropy/units/core.py index 000c13ff204..7a58ed8b358 100644 --- a/astropy/units/core.py +++ b/astropy/units/core.py @@ -1322,10 +1322,10 @@ def is_final_result(unit): for len_bases, composed, tunit in results: if len_bases > min_length: break - else: - factored = composed * tunit - if is_final_result(factored): - subresults.add(factored) + + factored = composed * tunit + if is_final_result(factored): + subresults.add(factored) if len(subresults): cached_results[key] = subresults