Skip to content
Closed
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
1 change: 1 addition & 0 deletions .buildkite/run_linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if is_pr && ! is_fork; then

if [ -z "$(git status --porcelain)" ]; then
echo "Nothing to be fixed by autoformat"
make lint
exit 0
else

Expand Down
2 changes: 1 addition & 1 deletion app/connectors_service/connectors/connectors_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def interactive_service_type_prompt():
clear_menu_on_exit=False,
show_search_hint=True,
).show()
return options[result]
return options[result] # type: ignore[assignment]


@click.command(help="Creates a new connector and a search index")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def validate(self, advanced_rules):
)
async def _remote_validation(self, advanced_rules):
try:
AtlassianAdvancedRulesValidator.SCHEMA(advanced_rules)
AtlassianAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _get_container_client(self, container_name):
try:
self.container_clients[container_name] = (
ContainerClient.from_connection_string(
conn_str=self.connection_string,
conn_str=self.connection_string, # type: ignore[arg-type]
container_name=container_name,
retry_total=self.retry_count,
)
Expand Down Expand Up @@ -247,7 +247,8 @@ async def get_container(self, container_list):
"""
container_set = set(container_list)
async with BlobServiceClient.from_connection_string(
conn_str=self.connection_string, retry_total=self.retry_count
conn_str=self.connection_string, # type: ignore[arg-type]
retry_total=self.retry_count,
) as azure_base_client:
try:
async for container in azure_base_client.list_containers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def validate(self, advanced_rules):
)
async def _remote_validation(self, advanced_rules):
try:
DropBoxAdvancedRulesValidator.SCHEMA(advanced_rules)
DropBoxAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
12 changes: 6 additions & 6 deletions app/connectors_service/connectors/sources/github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ async def _update_installation_access_token(self):
try:
access_token_response = await get_installation_access_token(
gh=self._get_client,
installation_id=self._installation_id,
app_id=self.app_id,
private_key=self.private_key,
installation_id=self._installation_id, # type: ignore[arg-type]
app_id=self.app_id, # type: ignore[arg-type]
private_key=self.private_key, # type: ignore[arg-type]
)
self._installation_access_token = access_token_response["token"]
except gidgethub.RateLimitExceeded:
Expand Down Expand Up @@ -347,7 +347,7 @@ async def _github_app_get(self, url):
{},
b"",
sansio.accept_format(),
get_jwt(app_id=self.app_id, private_key=self.private_key),
get_jwt(app_id=self.app_id, private_key=self.private_key), # type: ignore[arg-type]
)
# we don't expect any 401 error as the jwt is freshly generated
except gidgethub.RateLimitExceeded:
Expand All @@ -368,9 +368,9 @@ async def get_installations(self):
async for installation in self._github_app_paginated_get(
url="/app/installations"
):
if installation["suspended_at"]:
if installation["suspended_at"]: # type: ignore[index]
self._logger.debug(
f"Skip installation '{installation['id']}' because it's suspended."
f"Skip installation '{installation['id']}' because it's suspended." # type: ignore[index]
)
continue
yield installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ async def _fetch_installations(self):
async for installation in self.github_client.get_installations():
if (
self.configuration["repo_type"] == "organization"
and installation["account"]["type"] == "Organization"
and installation["account"]["type"] == "Organization" # type: ignore[index]
) or (
self.configuration["repo_type"] == "other"
and installation["account"]["type"] == "User"
and installation["account"]["type"] == "User" # type: ignore[index]
):
self._installations[installation["account"]["login"]] = installation[
self._installations[installation["account"]["login"]] = installation[ # type: ignore[index]
"id"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def validate(self, advanced_rules):

async def _remote_validation(self, advanced_rules):
try:
GitHubAdvancedRulesValidator.SCHEMA(advanced_rules)
GitHubAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def validate(self, advanced_rules):
)

try:
GMailAdvancedRulesValidator.SCHEMA(advanced_rules)
GMailAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]

return SyncRuleValidationResult.valid_result(
rule_id=SyncRuleValidationResult.ADVANCED_RULES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def api_call(
f"Using the storage emulator at {STORAGE_EMULATOR_HOST}"
)
# Redirecting calls to fake Google Cloud Storage server for e2e test.
storage_client.discovery_document["rootUrl"] = (
storage_client.discovery_document["rootUrl"] = ( # type: ignore[index]
STORAGE_EMULATOR_HOST + "/"
)
resource_object = getattr(storage_client, resource)
Expand All @@ -100,7 +100,7 @@ async def api_call(
full_res=True,
)
)
async for page_items in first_page_with_next_attached:
async for page_items in first_page_with_next_attached: # type: ignore[misc]
yield page_items
else:
if sub_method:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async def _get(self, absolute_url, use_token=True):
url=absolute_url,
) as resp:
yield resp
except aiohttp.client_exceptions.ClientOSError:
except aiohttp.client_exceptions.ClientOSError: # type: ignore[attr-defined]
self._logger.error(
"Graph API dropped the connection. It might indicate, that connector makes too many requests - decrease concurrency settings, otherwise Graph API can block this app."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MongoAdvancedRulesValidator(AdvancedRulesValidator):

async def validate(self, advanced_rules):
try:
MongoAdvancedRulesValidator.SCHEMA(advanced_rules)
MongoAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]

return SyncRuleValidationResult.valid_result(
rule_id=SyncRuleValidationResult.ADVANCED_RULES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def validate(self, advanced_rules):
)
async def _remote_validation(self, advanced_rules):
try:
MSSQLAdvancedRulesValidator.SCHEMA(advanced_rules)
MSSQLAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def validate(self, advanced_rules):
)
async def _remote_validation(self, advanced_rules):
try:
MySQLAdvancedRulesValidator.SCHEMA(advanced_rules)
MySQLAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,10 @@ def list_file_permission(self, file_path, file_type, mode, access):
port=self.port,
) as file:
descriptor = self.security_info.get_descriptor(
file_descriptor=file.fd, info=SECURITY_INFO_DACL
file_descriptor=file.fd, # type: ignore[attr-defined]
info=SECURITY_INFO_DACL,
)
return descriptor.get_dacl()["aces"]
return descriptor.get_dacl()["aces"] # type: ignore[index]
except SMBOSError as error:
self._logger.error(
f"Cannot read the contents of file on path:{file_path}. Error {error}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def validate(self, advanced_rules):

async def validate_pattern(self, advanced_rules):
try:
NetworkDriveAdvancedRulesValidator.SCHEMA(advanced_rules)
NetworkDriveAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def validate(self, advanced_rules):

async def _remote_validation(self, advanced_rules):
try:
NotionAdvancedRulesValidator.SCHEMA(advanced_rules)
NotionAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def post(self, url, payload=None):
await self._handle_client_side_errors(e)
except ClientPayloadError as e:
retry_seconds = DEFAULT_RETRY_SECONDS
response_headers = e.headers or {}
response_headers = e.headers or {} # type: ignore[attr-defined]
if "Retry-After" in response_headers:
try:
retry_seconds = int(response_headers["Retry-After"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def validate(self, advanced_rules):
)

try:
OneDriveAdvancedRulesValidator.SCHEMA(advanced_rules)
OneDriveAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def validate(self, advanced_rules):
)
async def _remote_validation(self, advanced_rules):
try:
PostgreSQLAdvancedRulesValidator.SCHEMA(advanced_rules)
PostgreSQLAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
8 changes: 4 additions & 4 deletions app/connectors_service/connectors/sources/redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@ async def get_key_value(self, key, key_type):
"""
try:
if key_type == KeyType.HASH.value:
return await self._client.hgetall(key)
return await self._client.hgetall(key) # type: ignore[misc]
elif key_type == KeyType.STREAM.value:
return await self._client.xread({key: "0"})
elif key_type == KeyType.LIST.value:
return await self._client.lrange(key, 0, -1)
return await self._client.lrange(key, 0, -1) # type: ignore[misc]
elif key_type == KeyType.SET.value:
return await self._client.smembers(key)
return await self._client.smembers(key) # type: ignore[misc]
elif key_type == KeyType.ZSET.value:
return await self._client.zrange(key, 0, -1, withscores=True)
elif key_type == KeyType.JSON.value:
value = await self._client.execute_command("JSON.GET", key)
return json.loads(value)
return json.loads(value) # type: ignore[arg-type]
else:
value = await self._client.get(key)
if value is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def validate(self, advanced_rules):

async def _remote_validation(self, advanced_rules):
try:
RedisAdvancedRulesValidator.SCHEMA(advanced_rules)
RedisAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
2 changes: 1 addition & 1 deletion app/connectors_service/connectors/sources/s3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def client(self, region=None):
# these context manager will be stored in client_context list also client will be stored in clients dict with their region
s3_context_stack = AsyncExitStack()
s3_client = await s3_context_stack.enter_async_context(
self.session.client(
self.session.client( # type: ignore[arg-type]
service_name="s3",
config=self.config,
endpoint_url=AWS_ENDPOINT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def validate(self, advanced_rules):
SyncRuleValidationResult.ADVANCED_RULES
)
try:
S3AdvancedRulesValidator.SCHEMA(advanced_rules)
S3AdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
return SyncRuleValidationResult.valid_result(
rule_id=SyncRuleValidationResult.ADVANCED_RULES
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def validate(self, advanced_rules):
)
async def _remote_validation(self, advanced_rules):
try:
SalesforceAdvancedRulesValidator.SCHEMA(advanced_rules)
SalesforceAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def validate(self, advanced_rules):

async def _remote_validation(self, advanced_rules):
try:
ServiceNowAdvancedRulesValidator.SCHEMA(advanced_rules)
ServiceNowAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]
except fastjsonschema.JsonSchemaValueException as e:
return SyncRuleValidationResult(
rule_id=SyncRuleValidationResult.ADVANCED_RULES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async def _execute_api_call(self, resource, method, call_api_func, kwargs):
)

if RUNNING_FTEST and GOOGLE_API_FTEST_HOST:
workspace_client.discovery_document["rootUrl"] = (
workspace_client.discovery_document["rootUrl"] = ( # type: ignore[index]
GOOGLE_API_FTEST_HOST + "/"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ async def _post(self, absolute_url, payload=None, retry_count=0):
if absolute_url.endswith("/$batch"): # response code of $batch lies
await self._check_batch_items_for_errors(absolute_url, resp)
yield resp
except aiohttp.client_exceptions.ClientOSError:
except aiohttp.client_exceptions.ClientOSError: # type: ignore[attr-defined]
self._logger.warning(
"The Microsoft Graph API dropped the connection. It might indicate that the connector is making too many requests. Decrease concurrency settings, otherwise the Graph API may block this app."
)
Expand All @@ -404,7 +404,7 @@ async def _check_batch_items_for_errors(self, url, batch_resp):
if status != 200:
self._logger.warning(f"Batch request item failed with: {response}")
headers = response.get("headers", {})
req_info = RequestInfo(url=url, method="POST", headers=headers)
req_info = RequestInfo(url=url, method="POST", headers=headers) # type: ignore[call-arg]
raise ClientResponseError(
request_info=req_info,
headers=headers,
Expand All @@ -428,7 +428,7 @@ async def _get(self, absolute_url, retry_count=0):
headers=headers,
) as resp:
yield resp
except aiohttp.client_exceptions.ClientOSError:
except aiohttp.client_exceptions.ClientOSError: # type: ignore[attr-defined]
self._logger.warning(
"Graph API dropped the connection. It might indicate, that connector makes too many requests - decrease concurrency settings, otherwise Graph API can block this app."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SharepointOnlineAdvancedRulesValidator(AdvancedRulesValidator):

async def validate(self, advanced_rules):
try:
SharepointOnlineAdvancedRulesValidator.SCHEMA(advanced_rules)
SharepointOnlineAdvancedRulesValidator.SCHEMA(advanced_rules) # type: ignore[misc]

return SyncRuleValidationResult.valid_result(
rule_id=SyncRuleValidationResult.ADVANCED_RULES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ async def site_list_has_unique_role_assignments(self, site_list_name, site_url):
site_list_name=site_list_name,
)
)
return role.get("value", False)
return role.get("value", False) # type: ignore[attr-defined]

async def site_list_item_has_unique_role_assignments(
self, site_url, site_list_name, list_item_id
Expand All @@ -492,7 +492,7 @@ async def site_list_item_has_unique_role_assignments(
list_item_id=list_item_id,
)
)
return role.get("value", False)
return role.get("value", False) # type: ignore[attr-defined]

async def site_list_item_role_assignments(
self, site_url, site_list_name, list_item_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ async def get_docs(self, filtering=None):
site_access_control,
site_admin_access_control,
) = await self._site_access_control(
site_url=f'{self.sharepoint_client.host_url}{site_data.get("ServerRelativeUrl")}'
site_url=f'{self.sharepoint_client.host_url}{site_data.get("ServerRelativeUrl")}' # type: ignore[attr-defined]
)
site_document = self._decorate_with_access_control(
self.format_sites(item=site_data), site_access_control
Expand Down
5 changes: 2 additions & 3 deletions app/connectors_service/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ reportMissingImports = false
reportMissingModuleSource = false
reportOptionalMemberAccess = false
exclude = ["**/tests", "**/__pycache__"]
executionEnvironments = [
{ root = "./", venv = ".venv" }
]
venvPath = "."
venv = ".venv"

[tool.ruff]
target-version = "py310"
Expand Down