Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Nov 20, 2023
1 parent 062a9e6 commit 8bc4cb0
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 39 deletions.
17 changes: 9 additions & 8 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
pylint==3.0.2
flake8~=3.7
isort~=5.8
black~=22.3.0
httpretty~=1.0
flake8==6.1.0
isort==5.12.0
black==22.3.0
httpretty==1.1.4
mypy==0.931
sphinx~=7.1
sphinx==7.1.2
sphinx-rtd-theme==2.0.0rc4
sphinx-autodoc-typehints~=1.25
sphinx-autodoc-typehints==1.25.2
pytest==7.1.3
pytest-cov~=4.1
readme-renderer~=24.0
pytest-cov==4.1.0
readme-renderer==42.0
bleach==4.1.0 # transient dependency for readme-renderer
protobuf~=3.13
markupsafe>=2.0.1
codespell==2.1.0
requests==2.31.0
ruamel.yaml==0.17.21
flaky==3.7.0
4 changes: 2 additions & 2 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinx~=7.1
sphinx==7.1.2
sphinx-rtd-theme==2.0.0rc4
sphinx-autodoc-typehints~=1.25
sphinx-autodoc-typehints==1.25.2

# Need to install the api/sdk in the venv for autodoc. Modifying sys.path
# doesn't work for pkg_resources.
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ def _inject_current_span(cls, call_context: _AwsSdkCallContext):
# Lambda extension
################################################################################

_OPERATION_MAPPING = {
_OPERATION_MAPPING: Dict[str, _LambdaOperation] = {
op.operation_name(): op
for op in globals().values()
if inspect.isclass(op)
and issubclass(op, _LambdaOperation)
and not inspect.isabstract(op)
} # type: Dict[str, _LambdaOperation]
}


class _LambdaExtension(_AwsSdkExtension):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def before_service_call(cls, call_context: _AwsSdkCallContext, span: Span):
# SNS extension
################################################################################

_OPERATION_MAPPING = {
_OPERATION_MAPPING: Dict[str, _SnsOperation] = {
op.operation_name(): op
for op in globals().values()
if inspect.isclass(op)
and issubclass(op, _SnsOperation)
and not inspect.isabstract(op)
} # type: Dict[str, _SnsOperation]
}


class _SnsExtension(_AwsSdkExtension):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,21 @@ def __init__(self, client: _BotoClientT, args: Tuple[str, Dict[str, Any]]):
boto_meta = client.meta
service_model = boto_meta.service_model

self.service = service_model.service_name.lower() # type: str
self.operation = operation # type: str
self.params = params # type: Dict[str, Any]
self.service = service_model.service_name.lower()
self.operation = operation
self.params = params

# 'operation' and 'service' are essential for instrumentation.
# for all other attributes we extract them defensively. All of them should
# usually exist unless some future botocore version moved things.
self.region = self._get_attr(
boto_meta, "region_name"
) # type: Optional[str]
self.endpoint_url = self._get_attr(
self.region: Optional[str] = self._get_attr(boto_meta, "region_name")
self.endpoint_url: Optional[str] = self._get_attr(
boto_meta, "endpoint_url"
) # type: Optional[str]
)

self.api_version = self._get_attr(
self.api_version: Optional[str] = self._get_attr(
service_model, "api_version"
) # type: Optional[str]
)
# name of the service in proper casing
self.service_id = str(
self._get_attr(service_model, "service_id", self.service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def _unary_interceptor(request_or_iterator, context):
# we handle in our context wrapper.
# Here, we're interested in uncaught exceptions.
# pylint:disable=unidiomatic-typecheck
if type(error) != Exception:
if type(error) != Exception: # noqa: E721
span.record_exception(error)
raise error

Expand All @@ -101,7 +101,7 @@ async def _stream_interceptor(request_or_iterator, context):

except Exception as error:
# pylint:disable=unidiomatic-typecheck
if type(error) != Exception:
if type(error) != Exception: # noqa: E721
span.record_exception(error)
raise error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def telemetry_interceptor(request_or_iterator, context):
# we handle in our context wrapper.
# Here, we're interested in uncaught exceptions.
# pylint:disable=unidiomatic-typecheck
if type(error) != Exception:
if type(error) != Exception: # noqa: E721
span.record_exception(error)
raise error

Expand All @@ -342,6 +342,6 @@ def _intercept_server_stream(

except Exception as error:
# pylint:disable=unidiomatic-typecheck
if type(error) != Exception:
if type(error) != Exception: # noqa: E721
span.record_exception(error)
raise error
9 changes: 1 addition & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,7 @@ commands =
basepython: python3
recreate = True
deps =
-c dev-requirements.txt
flaky
pylint
flake8
isort
black
readme_renderer
httpretty
-r dev-requirements.txt

commands_pre =
python -m pip install "{env:CORE_REPO}#egg=opentelemetry-api&subdirectory=opentelemetry-api"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def trysetip(conn: http.client.HTTPConnection, loglevel=logging.DEBUG) -> bool:
state = _getstate()
if not state:
return True
spanlist = state.get("need_ip") # type: typing.List[Span]
spanlist: typing.List[Span] = state.get("need_ip")
if not spanlist:
return True

Expand All @@ -88,7 +88,7 @@ def trysetip(conn: http.client.HTTPConnection, loglevel=logging.DEBUG) -> bool:

sock = "<property not accessed>"
try:
sock = conn.sock # type: typing.Optional[socket.socket]
sock: typing.Optional[socket.socket] = conn.sock
logger.debug("Got socket: %s", sock)
if sock is None:
return False
Expand Down Expand Up @@ -163,7 +163,7 @@ def set_ip_on_next_http_connection(span: Span):
finally:
context.detach(token)
else:
spans = state["need_ip"] # type: typing.List[Span]
spans: typing.List[Span] = state["need_ip"]
spans.append(span)
try:
yield
Expand Down

0 comments on commit 8bc4cb0

Please sign in to comment.