Skip to content

Commit 69b17d4

Browse files
authored
chore: remove azure-core dependency (#127)
1 parent d9c8095 commit 69b17d4

File tree

6 files changed

+70
-197
lines changed

6 files changed

+70
-197
lines changed

poetry.lock

Lines changed: 2 additions & 191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ license = { file="LICENSE" }
1919
keywords = ["fabric", "datafactory", "unit-testing", "functional-testing", "azure"]
2020

2121
dependencies = [
22-
"azure-core>=1.29.5,<2.0.0",
2322
"lark>=1.1.8,<2.0.0",
2423
"pythonnet>=3.0.3,<4.0.0"
2524
]
@@ -35,7 +34,6 @@ package-mode = false
3534

3635
[tool.poetry.dependencies]
3736
python = ">=3.9,<3.13"
38-
azure-core = "^1.29.5"
3937
lark = "^1.1.8"
4038
pythonnet = "^3.0.3"
4139

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# --------------------------------------------------------------------------
2+
#
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
#
5+
# The MIT License (MIT)
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the ""Software""), to
9+
# deal in the Software without restriction, including without limitation the
10+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11+
# sell copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in
15+
# all copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23+
# IN THE SOFTWARE.
24+
#
25+
# --------------------------------------------------------------------------
26+
from enum import Enum, EnumMeta
27+
from typing import Any
28+
29+
30+
class CaseInsensitiveEnumMeta(EnumMeta):
31+
"""Enum metaclass to allow for interoperability with case-insensitive strings.
32+
33+
Consuming this metaclass in an SDK should be done in the following manner:
34+
35+
.. code-block:: python
36+
37+
from enum import Enum
38+
from azure.core import CaseInsensitiveEnumMeta
39+
40+
class MyCustomEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
41+
FOO = 'foo'
42+
BAR = 'bar'
43+
44+
"""
45+
46+
def __getitem__(cls, name: str) -> Any: # noqa: N805, ANN401
47+
return super(CaseInsensitiveEnumMeta, cls).__getitem__(name.upper())
48+
49+
def __getattr__(cls, name: str) -> Enum: # noqa: N805
50+
"""Return the enum member matching `name`.
51+
52+
We use __getattr__ instead of descriptors or inserting into the enum
53+
class' __dict__ in order to support `name` and `value` being both
54+
properties for enum members (which live in the class' __dict__) and
55+
enum members themselves.
56+
57+
:param str name: The name of the enum member to retrieve.
58+
:rtype: ~azure.core.CaseInsensitiveEnumMeta
59+
:return: The enum member matching `name`.
60+
:raises AttributeError: If `name` is not a valid enum member.
61+
"""
62+
try:
63+
return cls._member_map_[name.upper()]
64+
except KeyError as err:
65+
raise AttributeError(name) from err

src/data_factory_testing_framework/_test_framework.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from enum import Enum
22
from typing import Iterator, List, Optional
33

4-
from azure.core import CaseInsensitiveEnumMeta
5-
4+
from data_factory_testing_framework._enum_meta import CaseInsensitiveEnumMeta
65
from data_factory_testing_framework._repositories._factories.data_factory_repository_factory import (
76
DataFactoryRepositoryFactory,
87
)

src/data_factory_testing_framework/state/_dependency_condition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
22

3-
from azure.core import CaseInsensitiveEnumMeta
3+
from data_factory_testing_framework._enum_meta import CaseInsensitiveEnumMeta
44

55

66
class DependencyCondition(str, Enum, metaclass=CaseInsensitiveEnumMeta):

src/data_factory_testing_framework/state/_run_parameter_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
22

3-
from azure.core import CaseInsensitiveEnumMeta
3+
from data_factory_testing_framework._enum_meta import CaseInsensitiveEnumMeta
44

55

66
class RunParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta):

0 commit comments

Comments
 (0)