From c2af85dc4e75a5c7eb58e2df99096bae163924eb Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Wed, 27 Nov 2024 13:37:07 -0500 Subject: [PATCH] Run pyupgrade to remove <3.11 stuff --- docs/conf.py | 7 +------ pyproject.toml | 1 - src/roman_datamodels/dqflags.py | 16 ++++------------ tests/test_dqflags.py | 11 ++--------- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 1b5b7852..408791d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,17 +14,12 @@ import importlib import os import sys +import tomllib from distutils.version import LooseVersion from pathlib import Path import sphinx -if sys.version_info < (3, 11): - import tomli as tomllib -else: - import tomllib - - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. diff --git a/pyproject.toml b/pyproject.toml index 13c765f8..84bbad2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ docs = [ "sphinx-automodapi", "sphinx-rtd-theme", "sphinx-astropy", - "tomli; python_version <\"3.11\"", ] [project.urls] diff --git a/src/roman_datamodels/dqflags.py b/src/roman_datamodels/dqflags.py index 061031ad..205d4841 100644 --- a/src/roman_datamodels/dqflags.py +++ b/src/roman_datamodels/dqflags.py @@ -19,24 +19,16 @@ the formula `2**bit_number` where `bit_number` is the 0-index bit of interest. """ -import sys -from enum import unique - # Something with pickling of multiclassed enums was changed in 3.11 + allowing # us to directly us `np.uint32` as the enum object rather than a python `int`. -if sys.version_info < (3, 11): - from enum import IntEnum -else: - from enum import Enum - - import numpy as np +from enum import Enum, unique - class IntEnum(np.uint32, Enum): ... +import numpy as np # fmt: off @unique -class pixel(IntEnum): +class pixel(np.uint32, Enum): """Pixel-specific data quality flags""" GOOD = 0 # No bits set, all is good @@ -74,7 +66,7 @@ class pixel(IntEnum): @unique -class group(IntEnum): +class group(np.uint32, Enum): """Group-specific data quality flags Once groups are combined, these flags are equivalent to the pixel-specific flags. """ diff --git a/tests/test_dqflags.py b/tests/test_dqflags.py index 02bab7eb..27694a0a 100644 --- a/tests/test_dqflags.py +++ b/tests/test_dqflags.py @@ -1,4 +1,3 @@ -import sys from math import log10 import numpy as np @@ -32,10 +31,7 @@ def test_pixel_flags(flag): assert isinstance(flag, dqflags.pixel) # Test that the pixel flags are ints - if sys.version_info < (3, 11): - assert isinstance(flag, int) - else: - assert isinstance(flag, np.uint32) + assert isinstance(flag, np.uint32) # Test that the pixel flags are dict accessible assert dqflags.pixel[flag.name] is flag @@ -83,10 +79,7 @@ def test_group_flags(flag): assert isinstance(flag, dqflags.group) # Test that the group flags are ints - if sys.version_info < (3, 11): - assert isinstance(flag, int) - else: - assert isinstance(flag, np.uint32) + assert isinstance(flag, np.uint32) # Test that the group flags are dict accessible assert dqflags.group[flag.name] is flag