Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Augan93 committed Jan 28, 2022
1 parent 7536856 commit ede1ad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->

@classmethod
def generate_streams(
cls, config: Mapping[str, Any], stream_names: List[str], sf_object: Salesforce, state: Mapping[str, Any] = None, stream_objects: List = None
cls,
config: Mapping[str, Any],
stream_names: List[str],
sf_object: Salesforce,
state: Mapping[str, Any] = None,
stream_objects: List = None,
) -> List[Stream]:
""" "Generates a list of stream by their names. It can be used for different tests too"""
authenticator = TokenAuthenticator(sf_object.access_token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#

import json
import csv
import io
import json
from unittest.mock import Mock

import pytest
Expand Down

1 comment on commit ede1ad2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarQube Report

SonarQube report for Airbyte Connectors Source Salesforce(#9499)

Measures

Name Value Name Value Name Value
Vulnerabilities 0 Code Smells 2 Duplicated Lines (%) 0.0
Security Rating A Reliability Rating A Coverage 42.0
Lines to Cover 50 Lines of Code 1210 Bugs 0
Duplicated Blocks 0 Quality Gate Status ERROR Blocker Issues 0
Critical Issues 4 Major Issues 9 Minor Issues 66

Detected Issues

Rule File Description Message
python:S5886 (MAJOR) source_salesforce/streams.py:251 Function return types should be consistent with their type hint Remove this yield statement or annotate function "download_data" with "typing.Generator" or one of its supertypes.
python:S1192 (CRITICAL) unit_tests/unit_test.py:75 String literals should not be duplicated Define a constant instead of duplicating this literal "https://fase-account.salesforce.com" 3 times.
python:black_need_format (MINOR) source_salesforce/source.py Please run one of the commands: "black --config ./pyproject.toml <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
flake8:E501 (MAJOR) source_salesforce/source.py line too long (82 > 79 characters) line too long (148 > 140 characters)
python:isort_need_format (MINOR) source_salesforce/source.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:mypy_import (MINOR) source_salesforce/source.py:14 Require that imported module can be found or has stubs Library stubs not installed for "requests" (or incompatible with Python 3.7) . Code line: from requests import codes, exceptions
python:isort_need_format (MINOR) unit_tests/unit_test.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:S1192 (CRITICAL) unit_tests/unit_test.py:341 String literals should not be duplicated Define a constant instead of duplicating this literal "TotalRequests Limit exceeded." 3 times.
python:isort_need_format (MINOR) integration_tests/bulk_error_test.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:S1192 (CRITICAL) unit_tests/unit_test.py:132 String literals should not be duplicated Define a constant instead of duplicating this literal "2122-08-22T05:08:29.000Z" 3 times.
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:47 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def path(self, next_page_token: Mapping[str, Any] = None, **kwargs...
python:mypy_return_value (MINOR) source_salesforce/streams.py:52 Check that return value is compatible with signature Incompatible return value type (got "Mapping[str, Any]", expected "str") . Code line: return next_page_token
python:mypy_no_any_return (MINOR) source_salesforce/streams.py:57 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "str" . Code line: return response_data.get("nextRecordsUrl")
python:mypy_valid_type (MINOR) source_salesforce/streams.py:266 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...e: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_pag...
python:mypy_operator (MINOR) source_salesforce/streams.py:275 Check that operator is valid for operands Unsupported operand types for + ("str" and "Mapping[str, Any]") . Code line: query += next_page_token
python:mypy_valid_type (MINOR) source_salesforce/streams.py:329 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...e: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_pag...
python:mypy_return (MINOR) source_salesforce/streams.py:365 Check that function always returns a value Missing return statement . Code line: def next_page_token(self, last_record: dict) -> str:
python:mypy_no_any_return (MINOR) source_salesforce/streams.py:367 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "str" . Code line: return last_record[self.cursor_field]
python:mypy_no_untyped_def (MINOR) source_salesforce/api.py:209 Check that every function has an annotation Function is missing a return type annotation . Code line: def get_validated_streams(self, config: Mapping[str, Any], catalog...
python:mypy_no_untyped_def (MINOR) source_salesforce/utils.py:6 Check that every function has an annotation Function is missing a return type annotation . Code line: def filter_streams(streams_list: list, search_word: str, search_criter...
python:mypy_import (MINOR) source_salesforce/api.py:10 Require that imported module can be found or has stubs Library stubs not installed for "requests.exceptions" (or incompatible with Python 3.7) . Code line: from requests.exceptions import HTTPError
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:236 Check that every function has an annotation Function is missing a return type annotation . Code line: def filter_null_bytes(self, s: str):
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:317 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def init(self, replication_key: str, start_date: Optional[str]...
python:mypy_return (MINOR) source_salesforce/streams.py:323 Check that function always returns a value Missing return statement . Code line: def format_start_date(start_date: Optional[str]) -> Optional[str]:
python:mypy_no_any_return (MINOR) source_salesforce/streams.py:326 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "Optional[str]" . Code line: return pendulum.parse(start_date).strftime("%Y-%m-%dT%H:%M...
python:mypy_attr_defined (MINOR) source_salesforce/streams.py:326 Check that attribute exists Module has no attribute "parse" . Code line: return pendulum.parse(start_date).strftime("%Y-%m-%dT%H:%M...
python:S5886 (MAJOR) source_salesforce/streams.py:222 Function return types should be consistent with their type hint Return a value of type "str" instead of "NoneType" or update function "execute_job" type hint.
python:mypy_attr_defined (MINOR) source_salesforce/streams.py:17 Check that attribute exists Module "pendulum" does not explicitly export attribute "DateTime"; implicit reexport disabled . Code line: from pendulum import DateTime
python:mypy_assignment (MINOR) source_salesforce/streams.py:84 Check that assigned value is compatible with target Incompatible types in assignment (expression has type "Mapping[str, Any]", variable has type "Optional[Dict[Any, Any]]") . Code line: self.schema = self.sf_api.generate_schema([self.name])
python:mypy_arg_type (MINOR) source_salesforce/streams.py:84 Check argument types in calls Argument 1 to "generate_schema" of "Salesforce" has incompatible type "List[str]"; expected "Optional[str]" . Code line: self.schema = self.sf_api.generate_schema([self.name])
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:114 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def init(self, wait_timeout: Optional[int], **kwargs):
python:mypy_assignment (MINOR) source_salesforce/streams.py:205 Check that assigned value is compatible with target Incompatible types in assignment (expression has type "float", variable has type "int") . Code line: delay_timeout = 0.5 + math.exp(delay_cnt) / 1000.0
python:S5799 (MAJOR) source_salesforce/streams.py:211 Implicit string and byte concatenations should not be confusing Merge these implicitly concatenated strings; or did you forget a comma?
python:S112 (MAJOR) source_salesforce/streams.py:233 "Exception" and "BaseException" should not be raised Replace this generic exception class with a more specific one.
flake8:E203 (MAJOR) unit_tests/unit_test.py:151 whitespace before ‘:’ whitespace before ':'
python:S125 (MAJOR) unit_tests/unit_test.py:220 Sections of code should not be commented out Remove this commented out code.
python:S5720 (CRITICAL) source_salesforce/streams.py:124 "self" should be the first argument to instance methods Rename "instance" to "self" or add the missing "self" parameter.
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:124 Check that every function has an annotation Function is missing a type annotation . Code line: def transform_empty_string_to_none(instance, schema):
python:mypy_has_type (MINOR) source_salesforce/streams.py:301 Check that type of reference can be determined Cannot determine type of "record" . Code line: yield record
python:isort_need_format (MINOR) main.py Please run one of the commands: "isort <path_to_updated_folder>" or "./gradlew format" 1 code part(s) should be updated.
python:mypy_no_untyped_def (MINOR) integration_tests/acceptance.py:12 Check that every function has an annotation Function is missing a return type annotation . Code line: def connector_setup():
python:mypy_import (MINOR) source_salesforce/api.py:7 Require that imported module can be found or has stubs Library stubs not installed for "requests" (or incompatible with Python 3.7) . Code line: import requests
python:mypy_no_untyped_def (MINOR) source_salesforce/api.py:177 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def init(
python:mypy_unreachable (MINOR) source_salesforce/api.py:194 Warn about unreachable statements or expressions Right operand of "and" is never evaluated . Code line: ...dbox is True or (isinstance(is_sandbox, str) and is_sandbox.lower() ==...
python:mypy_no_untyped_def (MINOR) source_salesforce/api.py:197 Check that every function has an annotation Function is missing a return type annotation . Code line: def _get_standard_headers(self):
python:mypy_no_untyped_def (MINOR) source_salesforce/api.py:249 Check that every function has an annotation Function is missing a return type annotation . Code line: def login(self):
python:mypy_no_any_return (MINOR) source_salesforce/api.py:274 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "Mapping[str, Any]" . Code line: return resp.json()
python:mypy_index (MINOR) source_salesforce/api.py:280 Check indexing operations Unsupported target for indexed assignment ("object") . Code line: schema["properties"][field["name"]] = self.field_to_proper...
python:mypy_dict_item (MINOR) source_salesforce/api.py:308 Check dict items in a dict expression {key: value, ...} Dict entry 1 has incompatible type "str": "str"; expected "str": "List[str]" . Code line: ... property_schema = {"type": ["string", "null"], "format": "date-time"...
python:mypy_dict_item (MINOR) source_salesforce/api.py:314 Check dict items in a dict expression {key: value, ...} Dict entry 1 has incompatible type "str": "Dict[str, Dict[str, List[str]]]"; expected "str": "List[str]" . Code line: "properties": {
python:mypy_dict_item (MINOR) source_salesforce/api.py:326 Check dict items in a dict expression {key: value, ...} Dict entry 1 has incompatible type "str": "str"; expected "str": "List[str]" . Code line: ... property_schema = {"type": ["string", "null"], "format": "base64"}
python:mypy_dict_item (MINOR) source_salesforce/api.py:340 Check dict items in a dict expression {key: value, ...} Dict entry 1 has incompatible type "str": "Dict[str, Dict[str, List[str]]]"; expected "str": "List[str]" . Code line: "properties": {"longitude": {"type": ["null", "number"...
python:mypy_import (MINOR) source_salesforce/rate_limiting.py:11 Require that imported module can be found or has stubs Library stubs not installed for "requests" (or incompatible with Python 3.7) . Code line: from requests import codes, exceptions
python:mypy_no_untyped_def (MINOR) source_salesforce/rate_limiting.py:24 Check that every function has an annotation Function is missing a return type annotation . Code line: def default_backoff_handler(max_tries: int, factor: int, **kwargs):
python:mypy_no_untyped_def (MINOR) source_salesforce/rate_limiting.py:24 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def default_backoff_handler(max_tries: int, factor: int, **kwargs):
python:mypy_no_untyped_def (MINOR) source_salesforce/rate_limiting.py:25 Check that every function has an annotation Function is missing a type annotation . Code line: def log_retry_attempt(details):
python:mypy_no_untyped_def (MINOR) source_salesforce/rate_limiting.py:30 Check that every function has an annotation Function is missing a type annotation . Code line: def should_give_up(exc):
python:mypy_return (MINOR) source_salesforce/source.py:27 Check that function always returns a value Missing return statement . Code line: def check_connection(self, logger: AirbyteLogger, config: Mapping[...
python:mypy_valid_type (MINOR) source_salesforce/source.py:27 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
python:mypy_assignment (MINOR) source_salesforce/source.py:65 Check that assigned value is compatible with target Incompatible types in assignment (expression has type "Type[BulkSalesforceStream]", variable has type "Type[SalesforceStream]") . Code line: full_refresh, incremental = BulkSalesforceStream, Bulk...
python:mypy_assignment (MINOR) source_salesforce/source.py:65 Check that assigned value is compatible with target Incompatible types in assignment (expression has type "Type[BulkSalesforceStream]", variable has type "Type[IncrementalSalesforceStream]") . Code line: ...ull_refresh, incremental = BulkSalesforceStream, BulkIncrementalSalesf...
flake8:E501 (MAJOR) source_salesforce/source.py:101 line too long (82 > 79 characters) line too long (149 > 140 characters)
python:S5886 (MAJOR) source_salesforce/streams.py Function return types should be consistent with their type hint Remove this yield statement or annotate function "download_data" with "typing.Generator" or one of its supertypes.
python:mypy_import (MINOR) source_salesforce/streams.py:13 Require that imported module can be found or has stubs Library stubs not installed for "requests" (or incompatible with Python 3.7) . Code line: import requests
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:28 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def init(self, sf_api: Salesforce, pk: str, stream_name: str, ...
python:mypy_valid_type (MINOR) source_salesforce/streams.py:60 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...e: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_pag...
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:79 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def parse_response(self, response: requests.Response, **kwargs) ->...
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:87 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def read_records(self, **kwargs) -> Iterable[Mapping[str, Any]]:
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:118 Check that every function has an annotation Function is missing a type annotation for one or more arguments . Code line: def path(self, **kwargs) -> str:
python:mypy_override (MINOR) source_salesforce/streams.py:118 Check that method override is compatible with base class Signature of "path" incompatible with supertype "SalesforceStream" . Code line: def path(self, **kwargs) -> str:
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:134 Check that every function has an annotation Function is missing a return type annotation . Code line: def _send_http_request(self, method: str, url: str, json: dict = N...
python:mypy_no_any_return (MINOR) source_salesforce/streams.py:152 Reject returning value with "Any" type if return type is not "Any" Returning Any from function declared to return "Optional[str]" . Code line: return job_id
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:253 Check that every function has an annotation Function is missing a return type annotation . Code line: def abort_job(self, url: str):
python:mypy_no_untyped_def (MINOR) source_salesforce/streams.py:258 Check that every function has an annotation Function is missing a return type annotation . Code line: def delete_job(self, url: str):
python:mypy_return (MINOR) source_salesforce/streams.py:261 Check that function always returns a value Missing return statement . Code line: def next_page_token(self, last_record: dict) -> str:
python:mypy_override (MINOR) source_salesforce/streams.py:282 Check that method override is compatible with base class Signature of "read_records" incompatible with supertype "SalesforceStream" . Code line: def read_records(
python:mypy_misc (MINOR) source_salesforce/streams.py:300 Miscellaneous other checks "object" object is not iterable . Code line: for count, record in self.download_data(url=job_full_url):
python:mypy_has_type (MINOR) source_salesforce/streams.py:308 Check that type of reference can be determined Cannot determine type of "record" . Code line: next_page_token = self.next_page_token(record)
python:mypy_valid_type (MINOR) source_salesforce/streams.py:370 Check that type (annotation) is valid Function "builtins.any" is not valid as a type . Code line: ...e: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_pag...

Coverage (42.0%)

File Coverage File Coverage
integration_tests/acceptance.py 0.0 integration_tests/bulk_error_test.py 0.0
main.py 0.0 setup.py 0.0
source_salesforce/init.py 100.0 source_salesforce/api.py 73.8
source_salesforce/exceptions.py 100.0 source_salesforce/rate_limiting.py 86.4
source_salesforce/source.py 85.3 source_salesforce/streams.py 87.0
source_salesforce/utils.py 100.0 unit_tests/unit_test.py 0.0

Please sign in to comment.