diff --git a/astrodata/__init__.py b/astrodata/__init__.py index 86b13486..96afde23 100644 --- a/astrodata/__init__.py +++ b/astrodata/__init__.py @@ -152,7 +152,7 @@ def create(*args, **kwargs): @deprecated( "Use 'astrodata.from_file'. astrodata.open is deprecated, " "and will be removed in a future version. They take the " - "same arguments and return the same object.", + "same arguments and return the same object." ) def open(*args, **kwargs): # pylint: disable=redefined-builtin """Return an |AstroData| object from a file. diff --git a/astrodata/testing.py b/astrodata/testing.py index 3e0e2a31..c372451b 100644 --- a/astrodata/testing.py +++ b/astrodata/testing.py @@ -201,13 +201,7 @@ def get_corners(shape): def assert_most_close( - actual, - desired, - max_miss, - rtol=1e-7, - atol=0, - equal_nan=True, - verbose=True, + actual, desired, max_miss, rtol=1e-7, atol=0, equal_nan=True, verbose=True ): """Assert that two objects are equal up to a specified number of elements. @@ -478,12 +472,7 @@ def compare_models(model1, model2, rtol=1e-7, atol=0.0, check_inverse=True): def download_multiple_files( - files, - path=None, - sub_path="", - use_threads=True, - sequential=False, - **kwargs, + files, path=None, sub_path="", use_threads=True, sequential=False, **kwargs ): """Download multiple files from the archive and store them at a given path. @@ -1202,10 +1191,7 @@ def fake_fits_bytes( min_choice, max_choice = 0, 64 mask = _RANDOM_NUMBER_GEN.integers( - min_choice, - max_choice, - size=image_shape, - dtype=np.uint16, + min_choice, max_choice, size=image_shape, dtype=np.uint16 ) # Setting some random pixels to zero on the mask @@ -1381,10 +1367,7 @@ def test_script_file( command = [x for x in itertools.chain(*command_components)] - process = subprocess.run( - command, - capture_output=True, - ) + process = subprocess.run(command, capture_output=True) stdout = process.stdout stderr = process.stderr diff --git a/astrodata/wcs.py b/astrodata/wcs.py index 7236d4be..07228716 100644 --- a/astrodata/wcs.py +++ b/astrodata/wcs.py @@ -99,7 +99,7 @@ def fitswcs_to_gwcs(input_data, *, raise_errors: bool = False): "Could not create gWCS: %s: %s", err.__class__.__name__, err, - ) + ) # fmt: skip return None @@ -474,9 +474,7 @@ def gwcs_to_fits(ndd, hdr=None): crval2 = wcs(*(crpix - 1)) try: sky_center = coord.SkyCoord( - nat2cel.lon.value, - nat2cel.lat.value, - unit=u.deg, + nat2cel.lon.value, nat2cel.lat.value, unit=u.deg ) except NameError: @@ -484,9 +482,7 @@ def gwcs_to_fits(ndd, hdr=None): else: sky_center2 = coord.SkyCoord( - crval2[lon_axis], - crval2[lat_axis], - unit=u.deg, + crval2[lon_axis], crval2[lat_axis], unit=u.deg ) if sky_center.separation(sky_center2).arcsec > 0.01: diff --git a/noxfile.py b/noxfile.py index fedbe88d..eb745abd 100644 --- a/noxfile.py +++ b/noxfile.py @@ -89,7 +89,7 @@ class SessionVariables: "3.10", "3.11", "3.12", - ] + ] # fmt: skip # devpi server information devpi_host = "localhost" @@ -162,9 +162,7 @@ class DevpiServerManager: url: ClassVar[str] = SessionVariables.devpi_url() def __init__( - self, - session: nox.Session, - tmp_dir: Path | None = None, + self, session: nox.Session, tmp_dir: Path | None = None ) -> None: """Initialize the context manager.""" self.session = session @@ -214,11 +212,7 @@ def generate_config_file(self): with session.cd(tmp_dir): session.run("devpi-init", "--serverdir", ".") session.run( - "devpi-gen-config", - "--serverdir", - tmp_dir, - "--port", - str(port), + "devpi-gen-config", "--serverdir", tmp_dir, "--port", str(port) ) def wait_for_devpi_startup(self, session: nox.Session) -> bool: @@ -275,22 +269,13 @@ def start_devpi_server(self): # Check that the server is available.abs result = session.run( - "which", - "devpi-server", - silent=True, - external=True, + "which", "devpi-server", silent=True, external=True ) devpi_server_path = result.strip() self.server_process = subprocess.Popen( - [ - devpi_server_path, - "--serverdir", - tmp_dir, - "--port", - str(port), - ], # noqa: S603 + [devpi_server_path, "--serverdir", tmp_dir, "--port", str(port)], # noqa: S603 stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) @@ -393,11 +378,7 @@ def get_poetry_dependencies( command[2] = f"--with={','.join(groups)}" - session.run( - *command, - external=True, - silent=True, - ) + session.run(*command, external=True, silent=True) log_message = f"Poetry dependencies written to {req_file_path}" @@ -554,11 +535,7 @@ def dragons_release_tests(session: nox.Session) -> None: # Positional arguments after -- are passed to pytest. pos_args = session.posargs - session.run( - "pytest", - *SessionVariables.dragons_pytest_options, - *pos_args, - ) + session.run("pytest", *SessionVariables.dragons_pytest_options, *pos_args) @nox.session(venv_backend="conda", python="3.12", tags=["dragons"]) @@ -635,11 +612,7 @@ def dragons_dev_tests(session: nox.Session) -> None: # Positional arguments after -- are passed to pytest. pos_args = session.posargs - session.run( - "pytest", - *SessionVariables.dragons_pytest_options, - *pos_args, - ) + session.run("pytest", *SessionVariables.dragons_pytest_options, *pos_args) @nox.session(python=SessionVariables.python_versions) @@ -661,14 +634,8 @@ def conda_unit_tests(session: nox.Session) -> None: """Run the unit tests.""" # Configure session channels. apply_data_caching_environment_variable(session) - session.run( - "conda", - "config", - "--env", - "--add", - "channels", - "conda-forge", - ) + session.run("conda", "config", "--env", "--add", "channels", "conda-forge") + # Conda-install the dependencies required to *run* astrodata since # this is a conda test. Then install the dependencies to run the *tests* # with pip since they are not all available from conda. @@ -700,9 +667,7 @@ def unit_test_build(session: nox.Session) -> None: install_test_dependencies(session, poetry_groups=["test"]) # Install the package from the devpi server - session.install( - "astrodata", - ) + session.install("astrodata") # Positional arguments after -- are passed to pytest. pos_args = session.posargs @@ -738,11 +703,7 @@ def integration_test_build(session: nox.Session) -> None: # Positional arguments after -- are passed to pytest. pos_args = session.posargs - session.run( - "pytest", - *SessionVariables.dragons_pytest_options, - *pos_args, - ) + session.run("pytest", *SessionVariables.dragons_pytest_options, *pos_args) @nox.session @@ -808,12 +769,7 @@ def build_and_publish_to_devpi(session: nox.Session): tmp_build_dir = Path(session.create_tmp()) / "build" tmp_build_dir.mkdir() - session.run( - "poetry", - "build", - f"--output={tmp_build_dir}", - external=True, - ) + session.run("poetry", "build", f"--output={tmp_build_dir}", external=True) # Shows available indexes poetry_config_env_vars = { @@ -1105,8 +1061,7 @@ def initialize_pre_commit(session: nox.Session) -> None: # above. They are separated here for ease of diagnosis for common problems. @nox.session(venv_backend="conda", python="3.12") def dragons_calibration( - session: nox.Session, - dragonsrc_path: Path | None = None, + session: nox.Session, dragonsrc_path: Path | None = None ) -> None: """Run the calibration tests.""" apply_data_caching_environment_variable(session) diff --git a/pyproject.toml b/pyproject.toml index c2091d05..956c79a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -218,6 +218,9 @@ ignore = [ [tool.ruff.format] skip-magic-trailing-comma = true +[tool.ruff.lint.isort] +split-on-trailing-comma = false + [tool.ruff.lint.pydocstyle] convention = "numpy"