Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove code paths for python <3.11 #9445

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 0 additions & 4 deletions tests/everest/entry_points/test_visualization_entry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import sys
from pathlib import Path
from unittest.mock import patch

import pytest

from everest.bin.visualization_script import visualization_entry
from everest.detached import ServerStatus
from tests.everest.utils import capture_streams
Expand All @@ -13,7 +10,6 @@
"everest.bin.visualization_script.everserver_status",
return_value={"status": ServerStatus.completed},
)
@pytest.mark.skipif(sys.version_info.major < 3, reason="requires python3 or higher")
def test_visualization_entry(_, cached_example):
JHolba marked this conversation as resolved.
Show resolved Hide resolved
config_path, config_file, _ = cached_example("math_func/config_advanced.yml")
with capture_streams() as (out, _):
Expand Down
Loading