Skip to content

Commit

Permalink
Run pyupgrade to remove <3.11 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Dec 2, 2024
1 parent 5993bb8 commit 2e46c41
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
7 changes: 1 addition & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ docs = [
"sphinx-automodapi",
"sphinx-rtd-theme",
"sphinx-astropy",
"tomli; python_version <\"3.11\"",
]

[project.urls]
Expand Down
16 changes: 4 additions & 12 deletions src/roman_datamodels/dqflags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
"""
Expand Down
11 changes: 2 additions & 9 deletions tests/test_dqflags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from math import log10

import numpy as np
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2e46c41

Please sign in to comment.