Skip to content

Commit

Permalink
Remove code paths for python <3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
JHolba committed Dec 4, 2024
1 parent 0ba0626 commit 89c55a3
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 93 deletions.
8 changes: 1 addition & 7 deletions src/_ert/events.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import sys
from datetime import datetime
from typing import Any, Dict, Final, Literal, Union

if sys.version_info < (3, 9):
from typing_extensions import Annotated
else:
from typing import Annotated
from typing import Annotated, Any, Dict, Final, Literal, Union

from pydantic import BaseModel, ConfigDict, Field, TypeAdapter

Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/analysis_mode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class AnalysisMode(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/config_keywords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class ConfigKeys(StrEnum):
Expand Down
3 changes: 1 addition & 2 deletions src/ert/config/parsing/config_schema_item.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import shutil
from enum import EnumType
from typing import List, Mapping, Optional, TypeVar, Union

from pydantic import ConfigDict, Field, NonNegativeInt, PositiveInt
from pydantic.dataclasses import dataclass

from ert.enum_shim import EnumType

from .config_errors import ConfigValidationError
from .context_values import (
ContextBool,
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/forward_model_keywords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class ForwardModelStepKeys(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/history_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class HistorySource(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/hook_runtime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class HookRuntime(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/queue_system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class QueueSystem(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/schema_item_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class SchemaItemType(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/workflow_job_keywords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class WorkflowJobKeys(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/parsing/workflow_keywords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class WorkflowKeys(StrEnum):
Expand Down
8 changes: 1 addition & 7 deletions src/ert/dark_storage/json_schema/prior.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import sys
from typing import Union
from typing import Literal, Union

from pydantic import BaseModel

if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal


class PriorConst(BaseModel):
"""
Expand Down
13 changes: 0 additions & 13 deletions src/ert/enum_shim.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/ert/field_utils/field_file_format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ert.enum_shim import StrEnum
from enum import StrEnum


class FieldFileFormat(StrEnum):
Expand Down
10 changes: 2 additions & 8 deletions src/ert/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

import logging
import os
import sys
from collections import Counter
from importlib.resources import files
from signal import SIG_DFL, SIGINT, signal
from typing import Optional, Tuple

if sys.version_info >= (3, 9):
from importlib.resources import files
else:
from importlib_resources import files

from collections import Counter

from qtpy.QtCore import QDir
from qtpy.QtGui import QIcon
from qtpy.QtWidgets import QApplication, QWidget
Expand Down
6 changes: 0 additions & 6 deletions src/everest/docs/generate_docs_from_config_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ def doc_description(self) -> str:
)

def clean_type(self) -> str:
if sys.version_info < (3, 10):
self.type = self.type.replace("Annotated[int, Ge(ge=0)]", "NonNegativeInt")
self.type = self.type.replace("Annotated[int, Gt(gt=0)]", "PositiveInt")
self.type = self.type.replace("Annotated[float, Gt(gt=0)]", "PositiveFloat")
self.type = re.sub(r"Union\[(.+),\s+NoneType\]", r"Optional[\1]", self.type)

self.type = self.type.replace("Annotated[int, Ge]", "NonNegativeInt")
self.type = self.type.replace("Annotated[int, Gt]", "PositiveInt")
self.type = self.type.replace("Annotated[float, Gt]", "PositiveFloat")
Expand Down
11 changes: 1 addition & 10 deletions src/everest/export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import re
import sys
from enum import StrEnum
from typing import Any, Dict, List, Optional, Set

import pandas as pd
Expand All @@ -11,15 +11,6 @@
from everest.config import ExportConfig
from everest.strings import STORAGE_DIR

if sys.version_info < (3, 11):
from enum import Enum

class StrEnum(str, Enum):
pass

else:
from enum import StrEnum


class MetaDataColumnNames(StrEnum):
# NOTE: Always add a new column name to the list below!
Expand Down
12 changes: 3 additions & 9 deletions tests/ert/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@
import shutil
import sys
from argparse import ArgumentParser
from importlib.resources import files
from pathlib import Path
from unittest.mock import MagicMock

from qtpy.QtWidgets import QApplication

from _ert.threading import set_signal_handler

if sys.version_info >= (3, 9):
from importlib.resources import files
else:
from importlib_resources import files

import pytest
from hypothesis import HealthCheck, settings
from hypothesis import strategies as st
from qtpy.QtCore import QDir
from qtpy.QtWidgets import QApplication

import _ert.forward_model_runner.cli
from _ert.threading import set_signal_handler
from ert.__main__ import ert_parser
from ert.cli.main import run_cli
from ert.config import ErtConfig
Expand Down
21 changes: 0 additions & 21 deletions tests/everest/entry_points/test_visualization_entry.py

This file was deleted.

0 comments on commit 89c55a3

Please sign in to comment.