Skip to content

Commit 630bccc

Browse files
committed
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-python into expose_length
* 'master' of https://github.com/Azure/azure-sdk-for-python: [textanalytics] add :keyword: to docstrings for TextDocumentInput and DetectLanguageInput (Azure#16542) [SB] combine conn str parser logic in base handler and _common (Azure#16464) [text analytics] add analyze readme bullet point (Azure#16552) resolve issues with failing search documents on mindependency checks (Azure#16553) [text analytics] analyze changes (Azure#16418) [Core] Added enum meta class (Azure#16316) Adding missing supported fields to invoice sample (Azure#16547) Update EventHub ci.yml to skip unsupported pypy3 (Azure#16545) patching the publishing of artifacts only on successful run (Azure#16539) need to bump msrest up one (Azure#16544) [EventHub&ServiceBUs] Update readme pointing to uamqp installation guidance (added alpine installation) (Azure#16515) add dotenv as a dep for azure-sdk-tools (Azure#16532) skip prebuilt from_url tests for now (Azure#16534) Latest/Minimum filter retrieved packages by pyVersion compatibility (Azure#16510) CertificateCredential accepts certs as bytes (Azure#16410)
2 parents 001942a + 6bae810 commit 630bccc

File tree

137 files changed

+6473
-28692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+6473
-28692
lines changed

eng/dependency_tools.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
../../../tools/azure-sdk-tools
1+
../../../tools/azure-sdk-tools
2+
aiohttp>=3.0; python_version >= '3.5'

eng/pipelines/templates/steps/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ steps:
6161
Get-Content $_
6262
}
6363
displayName: 'Show .coverage files'
64-
condition: and(succeededOrFailed(), ${{ parameters.RunCoverage }})
64+
condition: and(succeeded(), ${{ parameters.RunCoverage }})
6565
6666
- task: PublishPipelineArtifact@1
6767
displayName: 'Publish .coverage files'
6868
continueOnError: true
69-
condition: and(succeededOrFailed(), ${{ parameters.RunCoverage }})
69+
condition: and(succeeded(), ${{ parameters.RunCoverage }})
7070
inputs:
7171
targetPath: '$(Build.SourcesDirectory)/_coverage'
7272
artifactType: 'pipeline'

eng/tox/install_depend_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def process_requirement(req, dependency_type):
8484

8585
# get available versions on PyPI
8686
client = PyPIClient()
87-
versions = [str(v) for v in client.get_ordered_versions(pkg_name)]
87+
versions = [str(v) for v in client.get_ordered_versions(pkg_name, True)]
8888
logging.info("Versions available on PyPI for %s: %s", pkg_name, versions)
8989

9090
if pkg_name in MINIMUM_VERSION_SUPPORTED_OVERRIDE:

scripts/devops_tasks/common_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"azure",
4444
"azure-mgmt",
4545
"azure-storage",
46+
"azure-mgmt-regionmove"
4647
]
4748
MANAGEMENT_PACKAGE_IDENTIFIERS = [
4849
"mgmt",

sdk/core/azure-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- Added `CaseInsensitiveEnumMeta` class for case-insensitive enums. #16316
78
- Add `raise_for_status` method onto `HttpResponse`. Calling `response.raise_for_status()` on a response with an error code
89
will raise an `HttpResponseError`. Calling it on a good response will do nothing #16399
910

sdk/core/azure-core/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ class MatchConditions(Enum):
148148
IfMissing = 5
149149
```
150150

151+
#### CaseInsensitiveEnumMeta
152+
153+
A metaclass to support case-insensitive enums.
154+
```python
155+
from enum import Enum
156+
from six import with_metaclass
157+
158+
from azure.core import CaseInsensitiveEnumMeta
159+
160+
class MyCustomEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
161+
FOO = 'foo'
162+
BAR = 'bar'
163+
```
164+
151165
## Contributing
152166
This project welcomes contributions and suggestions. Most contributions require
153167
you to agree to a Contributor License Agreement (CLA) declaring that you have

sdk/core/azure-core/azure/core/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929

3030
from ._pipeline_client import PipelineClient
3131
from ._match_conditions import MatchConditions
32+
from ._enum_meta import CaseInsensitiveEnumMeta
3233

3334

3435
__all__ = [
3536
"PipelineClient",
36-
"MatchConditions"
37+
"MatchConditions",
38+
"CaseInsensitiveEnumMeta"
3739
]
3840

3941
try:
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
27+
from enum import EnumMeta
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 six import with_metaclass
39+
from azure.core import CaseInsensitiveEnumMeta
40+
41+
class MyCustomEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
42+
FOO = 'foo'
43+
BAR = 'bar'
44+
45+
"""
46+
47+
def __getitem__(cls, name):
48+
# disabling pylint bc of pylint bug https://github.com/PyCQA/astroid/issues/713
49+
return super(CaseInsensitiveEnumMeta, cls).__getitem__(name.upper()) # pylint: disable=no-value-for-parameter
50+
51+
def __getattr__(cls, name):
52+
"""Return the enum member matching `name`
53+
We use __getattr__ instead of descriptors or inserting into the enum
54+
class' __dict__ in order to support `name` and `value` being both
55+
properties for enum members (which live in the class' __dict__) and
56+
enum members themselves.
57+
"""
58+
try:
59+
return cls._member_map_[name.upper()]
60+
except KeyError:
61+
raise AttributeError(name)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# 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 FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
# THE SOFTWARE.
24+
#
25+
# --------------------------------------------------------------------------
26+
from enum import Enum
27+
from six import with_metaclass
28+
29+
from azure.core import CaseInsensitiveEnumMeta
30+
31+
class MyCustomEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
32+
FOO = 'foo'
33+
BAR = 'bar'
34+
35+
36+
def test_case_insensitive_enums():
37+
assert MyCustomEnum.foo.value == 'foo'
38+
assert MyCustomEnum.FOO.value == 'foo'
39+
assert MyCustomEnum('bar').value == 'bar'
40+
assert 'bar' == MyCustomEnum.BAR
41+
assert 'bar' == MyCustomEnum.bar
42+
assert MyCustomEnum['foo'] == 'foo'
43+
assert MyCustomEnum['FOO'] == 'foo'
44+
assert isinstance(MyCustomEnum.BAR, str)

sdk/eventhub/azure-eventhub/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,14 @@ Reference documentation is available [here](https://azuresdkdocs.blob.core.windo
423423
The EventHubs SDK integrates nicely with the [Schema Registry][schemaregistry_service] service and [Avro][avro].
424424
For more information, please refer to [Schema Registry SDK][schemaregistry_repo] and [Schema Registry Avro Serializer SDK][schemaregistry_avroserializer_repo].
425425

426+
### Building uAMQP wheel from source
427+
428+
`azure-eventhub` depends on the [uAMQP](https://pypi.org/project/uamqp/) for the AMQP protocol implementation.
429+
uAMQP wheels are provided for most major operating systems and will be installed automatically when installing `azure-eventhub`.
430+
431+
If you're running on a platform for which uAMQP wheels are not provided, please follow
432+
the [uAMQP Installation](https://github.com/Azure/azure-uamqp-python#installation) guidance to install from source.
433+
426434
### Provide Feedback
427435

428436
If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project.

0 commit comments

Comments
 (0)