Skip to content

Commit c98ce73

Browse files
Kamal Sai DevarapalliKamal Sai Devarapalli
authored andcommitted
Fix linting issues: unused imports and code style
- Remove unused concurrent.futures import from usermanagement/__init__.py - Remove duplicate sys and os imports - Remove unused json import from find_good_first_issue.py - Fix line length issues in commented code - Add pylint disable comments for intentional import order - Fix whitespace in blank lines - Add pylint disable for Kafka producer exception handling
1 parent 1850cce commit c98ce73

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

scripts/find_good_first_issue.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
import requests
66
import sys
7-
import json
87

98
def find_good_first_issues(repo, token=None):
109
"""Find good first issues in a repository"""

services/usermanagement/app/__init__.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# pylint: disable=line-too-long
22
import os
33
import sys
4-
import concurrent.futures
54
from logging import Logger
65
from flask import Flask, Blueprint
7-
import sys
8-
import os
6+
97
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../..'))
108

11-
from common.pyportal_common.logging_handlers.base_logger import LogMonitor
12-
from common.pyportal_common.app_handlers.app_manager import AppHandler
13-
from app.app_configs import init_app_configs
14-
from app.models.user_model import UserBase
9+
# pylint: disable=wrong-import-position
10+
# Imports must come after sys.path modification
11+
from common.pyportal_common.logging_handlers.base_logger import ( # noqa: E402
12+
LogMonitor
13+
)
14+
from common.pyportal_common.app_handlers.app_manager import ( # noqa: E402
15+
AppHandler
16+
)
17+
from app.app_configs import init_app_configs # noqa: E402
18+
from app.models.user_model import UserBase # noqa: E402
1519

1620
# Initialize variables
1721
user_management_logger = None
@@ -90,7 +94,7 @@
9094
sys.exit()
9195

9296
init_app_configs(usermanager_app)
93-
97+
9498
# Add health check endpoint (before database initialization)
9599
@usermanager_app.route('/health', methods=['GET'])
96100
def health():
@@ -100,7 +104,7 @@ def health():
100104
'status': 'healthy',
101105
'service': 'usermanagement'
102106
}), 200
103-
107+
104108
# Load and Validate Schema Files which are read.
105109
(
106110
req_headers_schema_status,
@@ -152,9 +156,9 @@ def health():
152156
user_management_grpc_server = (
153157
start_user_management_grpc_server(user_management_logger)
154158
)
155-
except Exception as ex:
159+
except Exception as ex: # pylint: disable=broad-except
156160
user_management_logger.warning(
157-
f"Failed to initialize gRPC server: {ex}"
161+
"Failed to initialize gRPC server: %s", ex
158162
)
159163
user_management_grpc_server = None
160164

@@ -166,13 +170,16 @@ def health():
166170
)
167171
user_management_kafka_producer = (
168172
init_kafka_usermangement_producer.
169-
start_user_management_kafka_producer(user_management_logger)
173+
start_user_management_kafka_producer(
174+
user_management_logger
175+
)
170176
)
177+
# pylint: disable=broad-except
171178
except Exception as ex:
172179
user_management_logger.warning(
173-
f"Failed to initialize Kafka producer: {ex}"
180+
"Failed to initialize Kafka producer: %s", ex
174181
)
175-
182+
176183
# Export for use in views
177184
__all__ = [
178185
"user_management_logger",
@@ -201,7 +208,8 @@ def health():
201208
# '/api/v1/eventstreammonitor/users/<int:userid>', methods=['GET']
202209
# )(get_user_info)
203210
# usermanager_bp.route(
204-
# '/api/v1/eventstreammonitor/users/<int:userid>', methods=['DELETE']
211+
# '/api/v1/eventstreammonitor/users/<int:userid>',
212+
# methods=['DELETE']
205213
# )(deregister_user)
206214

207215
usermanager.register_blueprint_for_service(
@@ -211,7 +219,7 @@ def health():
211219
usermanager.display_registered_blueprints_for_service(
212220
app_instance=usermanager_app
213221
)
214-
except Exception as ex:
222+
except Exception as ex: # pylint: disable=broad-except
215223
print(f"Exception in __init__: {ex}")
216224
import traceback
217225
traceback.print_exc()

0 commit comments

Comments
 (0)