Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #331

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
stages: [commit]
args: ["--profile", "black"]

- repo: https://github.com/PyCQA/autoflake
rev: v1.5.3
rev: v2.3.1
hooks:
- id: autoflake
stages: [commit]
Expand All @@ -21,7 +21,7 @@ repos:
]

- repo: https://github.com/psf/black
rev: 22.8.0
rev: 24.8.0
hooks:
- id: black
stages: [commit]
1 change: 0 additions & 1 deletion licenseware/app_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@

"""


from .app_builder import AppBuilder
6 changes: 3 additions & 3 deletions licenseware/app_builder/app_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ def after_request(response):
)
response.headers.set("Access-Control-Allow-Credentials", "true")
# FORCE HTTPS
response.headers[
"Strict-Transport-Security"
] = "max-age=31536000; includeSubDomains"
response.headers["Strict-Transport-Security"] = (
"max-age=31536000; includeSubDomains"
)
# XSS
response.headers["X-XSS-Protection"] = "1; mode=block"
response.headers["X-Content-Type-Options"] = "nosniff"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def get_data(self, flask_request):


class DataSyncRoute(SchemaNamespace):

"""
Create a data sync endpoint with machine authorization.
Receives a schema and a collection name as optional (it will use mongo data collection by default)
Expand All @@ -43,8 +42,7 @@ def __init__(self, ns: Namespace, schema: Schema, collection_name: str = None):


def get_data_sync_namespace(ns: Namespace, data_sync_schema: Schema):
class DataSyncSchema(data_sync_schema):
...
class DataSyncSchema(data_sync_schema): ...

collection_name = None
if hasattr(data_sync_schema, "Meta"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def get_report_image_preview_dark_namespace(
500: "Could not return the image",
},
)
class TempReportResource(RR):
...
class TempReportResource(RR): ...

ReportResource = type(
report.report_id.replace("_", "").capitalize() + "previewImageDark",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def get_report_image_preview_namespace(ns: Namespace, reports: List[ReportBuilde
500: "Could not return the image",
},
)
class TempReportResource(RR):
...
class TempReportResource(RR): ...

ReportResource = type(
report.report_id.replace("_", "").capitalize() + "previewImage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def get_report_register_namespace(ns: Namespace, reports: List[ReportBuilder]):
500: "Could not register report",
},
)
class TempReportResource(RR):
...
class TempReportResource(RR): ...

ReportResource = type(
report.report_id.replace("_", "").capitalize() + "register",
Expand Down
1 change: 0 additions & 1 deletion licenseware/app_builder/tenant_registration_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

"""


from flask import request
from flask_restx import Api, Resource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

"""


from typing import List

from flask import request
Expand Down Expand Up @@ -78,8 +77,7 @@ def get_filenames_validation_namespace(ns: Namespace, uploaders: List[UploaderBu
description="Filenames validation response",
model=filenames_resp_model,
)
class TempUploaderResource(UR):
...
class TempUploaderResource(UR): ...

# Adding extra swagger query parameters if provided
if uploader.query_params_on_validation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

"""


from typing import List

from flask import request
Expand Down Expand Up @@ -116,8 +115,7 @@ def get_filestream_validation_namespace(
@ns.response(
code=200, description="Upload response", model=file_validation_resp_model
)
class TempUploaderResource(UR):
...
class TempUploaderResource(UR): ...

# Adding extra swagger query parameters if provided
if uploader.query_params_on_upload:
Expand Down
3 changes: 1 addition & 2 deletions licenseware/app_builder/uploads_namespace/quota_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def get_quota_namespace(ns: Namespace, uploaders: List[UploaderBuilder]):
@ns.response(
code=200, description="Utilization within monthly quota", model=quota_model
)
class TempUploaderResource(UR):
...
class TempUploaderResource(UR): ...

UploaderResource = type(
uploader.uploader_id.replace("_", "").capitalize() + "quota",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def get_status_namespace(ns: Namespace, uploaders: List[UploaderBuilder]):
500: "Something went wrong while handling the request",
},
)
class TempUploaderResource(UR):
...
class TempUploaderResource(UR): ...

UploaderResource = type(
uploader.uploader_id.replace("_", "").capitalize() + "status",
Expand Down
1 change: 0 additions & 1 deletion licenseware/cli/base_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def create_file(
template_filename: str = None,
**template_vars
):

"""

This methods uses the jinja template to generate a new file.
Expand Down
1 change: 1 addition & 0 deletions licenseware/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Here all cli functions are gathered and decorated with typer app decorator.

"""

import json
import os
import shutil
Expand Down
19 changes: 9 additions & 10 deletions licenseware/common/marshmallow_restx_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def post(self):

"""


from typing import Callable, Union

import flask_restx as restx
Expand Down Expand Up @@ -232,20 +231,20 @@ def get_marshmallow_metadata(schema: Callable):
if field_data["nested"] is None:

if isinstance(field_data["raw"], ma.fields.Nested):
marshmallow_metadata[schema.__name__][field_name][
"nested"
] = get_marshmallow_metadata(field_data["raw"].nested)
marshmallow_metadata[schema.__name__][field_name]["nested"] = (
get_marshmallow_metadata(field_data["raw"].nested)
)

if isinstance(field_data["raw"], ma.fields.List):
if hasattr(field_data["raw"].inner, "nested"):
marshmallow_metadata[schema.__name__][field_name][
"nested"
] = get_marshmallow_metadata(field_data["raw"].inner.nested)
marshmallow_metadata[schema.__name__][field_name]["nested"] = (
get_marshmallow_metadata(field_data["raw"].inner.nested)
)
else:
# ex: ma.fields.List(ma.fields.String)
marshmallow_metadata[schema.__name__][field_name][
"inner"
] = get_field_data(field_data["raw"].inner)
marshmallow_metadata[schema.__name__][field_name]["inner"] = (
get_field_data(field_data["raw"].inner)
)

return marshmallow_metadata

Expand Down
1 change: 0 additions & 1 deletion licenseware/common/validators/file_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

"""


import itertools
import os
import re
Expand Down
7 changes: 2 additions & 5 deletions licenseware/endpoint_builder/endpoint_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def get_detected_uploaders(): # a function that takes no parameters


class EndpointBuilder:

"""
Usage:

Expand Down Expand Up @@ -133,15 +132,13 @@ def add_method_to_namespace(self, ns):

if self.apidoc:

class BaseResource(Resource):
...
class BaseResource(Resource): ...

BaseResource.__apidoc__ = self.apidoc
else:

@ns.doc(id=self.doc_id, description=self.doc_description)
class BaseResource(Resource):
...
class BaseResource(Resource): ...

CResource = type(
self.handler.__name__ + self.http_method.capitalize(),
Expand Down
1 change: 0 additions & 1 deletion licenseware/feature_builder/feature_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def post(self):

"""


from typing import List

from flask import Request
Expand Down
8 changes: 5 additions & 3 deletions licenseware/history/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def get_metadata(func, func_args, func_kwargs):
.strip()
.replace("'", "")
.replace(">", ""),
"tenant_id": tenant.get_tenant_id(func, func_args, func_kwargs)
if not envs.DESKTOP_ENVIRONMENT
else envs.DESKTOP_TENANT_ID,
"tenant_id": (
tenant.get_tenant_id(func, func_args, func_kwargs)
if not envs.DESKTOP_ENVIRONMENT
else envs.DESKTOP_TENANT_ID
),
"event_id": event.get_event_id(func, func_args, func_kwargs),
"app_id": envs.APP_ID,
"uploader_id": uploader.get_uploader_id(func, func_args, func_kwargs),
Expand Down
1 change: 0 additions & 1 deletion licenseware/quota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@

"""


from .quota import Quota
3 changes: 1 addition & 2 deletions licenseware/registry_service/register_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from licenseware.utils.logger import log


class RegistrationFailed(Exception):
...
class RegistrationFailed(Exception): ...


def registration_failed(retries_so_far: int, exception):
Expand Down
5 changes: 3 additions & 2 deletions licenseware/report_components/base_report_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ def set_attributes(self):
def set_style_attributes(self):
raise NotImplementedError("Please overwrite method `set_style_attributes`")

def set_allowed_filters(self):
... # Component filters are optional, Report filters are needed
def set_allowed_filters(
self,
): ... # Component filters are optional, Report filters are needed

def get_registration_payload(self):

Expand Down
6 changes: 2 additions & 4 deletions licenseware/repository/mongo_repository/mongo_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ def _setid(self, data: dict):

def _setids(self, cursor: Cursor):

getid = (
lambda doc: {"_id": utils.get_object_id_str(doc["_id"])}
if "_id" in doc
else {}
getid = lambda doc: (
{"_id": utils.get_object_id_str(doc["_id"])} if "_id" in doc else {}
)

return [{**doc, **getid(doc)} for doc in cursor]
Expand Down
Loading
Loading