Skip to content

Commit 16f6b89

Browse files
authored
Introduced Linting (#2)
1 parent 0d9d901 commit 16f6b89

20 files changed

+96
-58
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 120
3+
exclude = .git,__pycache__,venv

.github/workflows/pipeline.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,46 @@ on:
66
- '*'
77

88
jobs:
9+
lint:
10+
name: Python Linux (flake8)
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install Dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install flake8
26+
27+
- name: Run Lint
28+
run: flake8 --verbose --color auto --count --statistics --format=json --output-file=flake8-report.json || echo "::set-output name=flake8_failed::true"
29+
continue-on-error: true
30+
31+
- name: Upload Report
32+
if: ${{ always() }}
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: flake8-report
36+
path: flake8-report.json
37+
938
build_and_test:
39+
name: Build and Test
1040
runs-on: ubuntu-latest
41+
needs: lint
1142

1243
steps:
1344
- name: Checkout Repository
14-
uses: actions/checkout@v2
45+
uses: actions/checkout@v4
1546

1647
- name: Setup Python
17-
uses: actions/setup-python@v2
48+
uses: actions/setup-python@v5
1849
with:
1950
python-version: '3.10'
2051

pyloggermanager/__init__.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,35 @@
3939
"log",
4040
"disable",
4141
"shutdown",
42+
"formatters",
43+
"handlers",
44+
"streams",
45+
"textstyles",
4246
"__author__",
4347
"__description__",
4448
"__name__",
4549
"__version__"
4650
]
4751
__author__ = "coldsofttech"
4852
__description__ = """
49-
The pyloggermanager package is a vital logging framework for Python applications, providing developers with essential
50-
tools to streamline logging operations. Its primary function is to simplify the recording and organization of log
51-
messages, including critical information, debugging messages, errors, and warnings. By offering a centralized interface
53+
The pyloggermanager package is a vital logging framework for Python applications, providing developers with essential
54+
tools to streamline logging operations. Its primary function is to simplify the recording and organization of log
55+
messages, including critical information, debugging messages, errors, and warnings. By offering a centralized interface
5256
and robust functionalities, the package facilitates efficient monitoring and troubleshooting processes.
5357
54-
With its intuitive interface, the pyloggermanager package enables developers to seamlessly integrate logging mechanisms
55-
into their applications. This allows for systematic recording and categorization of log entries based on severity
56-
levels, enhancing readability and prioritization of issues. Moreover, the package offers flexibility in customizing
57-
logging configurations to suit specific project requirements, including formatting, output destinations, and thread
58+
With its intuitive interface, the pyloggermanager package enables developers to seamlessly integrate logging mechanisms
59+
into their applications. This allows for systematic recording and categorization of log entries based on severity
60+
levels, enhancing readability and prioritization of issues. Moreover, the package offers flexibility in customizing
61+
logging configurations to suit specific project requirements, including formatting, output destinations, and thread
5862
safety.
5963
60-
Beyond technical capabilities, the pyloggermanager package contributes to the reliability and maintainability of Python
61-
applications. It establishes consistent logging practices, simplifying collaboration, code reviews, and issue
62-
resolution across development teams. Overall, the pyloggermanager package is an invaluable asset for developers aiming
64+
Beyond technical capabilities, the pyloggermanager package contributes to the reliability and maintainability of Python
65+
applications. It establishes consistent logging practices, simplifying collaboration, code reviews, and issue
66+
resolution across development teams. Overall, the pyloggermanager package is an invaluable asset for developers aiming
6367
to implement robust logging solutions, ensuring efficient and resilient application performance.
6468
"""
6569
__name__ = "pyloggermanager"
66-
__version__ = "0.1.0"
70+
__version__ = "0.1.1"
6771

6872
from pyloggermanager import formatters
6973
from pyloggermanager import handlers

pyloggermanager/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def is_colorization_supported(cls) -> bool:
187187
if term is None:
188188
return False
189189

190-
if 'color' in os.popen(f'tput colors').read():
190+
if 'color' in os.popen('tput colors').read():
191191
return True
192192

193193
try:

pyloggermanager/formatters/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
as CSV (Comma-Separated Values), JSON (JavaScript Object Notation), and the default text format.
3636
3737
Below listed formatter classes enable users to customize the appearance and structure of log messages
38-
according to their requirements. By supporting different formats such as CSV and JSON, users have the
39-
flexibility to choose the most suitable format for their logging needs, whether it's for human-readable
38+
according to their requirements. By supporting different formats such as CSV and JSON, users have the
39+
flexibility to choose the most suitable format for their logging needs, whether it's for human-readable
4040
output, structured data storage, or integration with external systems.
4141
42-
Overall, the pyloggermanager.formatters package enhances the logger manager framework by offering
42+
Overall, the pyloggermanager.formatters package enhances the logger manager framework by offering
4343
versatile formatting options for log messages, catering to a wide range of logging use cases and
4444
preferences.
4545
"""

pyloggermanager/formatters/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def format_str(self, value: str | dict) -> None:
111111

112112
self._format_str = value
113113

114-
def format(self, record: 'Record') -> str:
114+
def format(self, record) -> str:
115115
"""
116116
Formats the log record into a string based on the provided record object.
117117
@@ -172,7 +172,7 @@ def format_exception(
172172
else:
173173
return ''
174174

175-
def _log_attributes(self, record: 'Record', date_format: str) -> dict:
175+
def _log_attributes(self, record, date_format: str) -> dict:
176176
"""
177177
Extracts and organizes various attributes of a 'Record' object into a dictionary format.
178178
@@ -226,7 +226,7 @@ def __init__(self, format_str: str = DEFAULT_FORMAT, date_format: str = DATE_FOR
226226

227227
super().__init__(format_str, date_format)
228228

229-
def format(self, record: 'Record') -> str:
229+
def format(self, record) -> str:
230230
"""
231231
Formats the given log record according to the format string.
232232
@@ -293,7 +293,7 @@ def _is_valid_csv_format(format_str: str) -> bool:
293293
"""
294294
return len(format_str.split(',')) >= 2
295295

296-
def format(self, record: 'Record') -> str:
296+
def format(self, record) -> str:
297297
"""
298298
Formats the given log record into a CSV string based on the specified format string.
299299
@@ -356,7 +356,7 @@ def _validate_format_str(format_str: dict) -> None:
356356
except ValueError:
357357
raise ValueError("Invalid JSON format string.")
358358

359-
def format(self, record: 'Record') -> str:
359+
def format(self, record) -> str:
360360
"""
361361
Formats the given log record into a JSON string.
362362

pyloggermanager/handlers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
__name__ = "pyloggermanager.handlers"
2929
__description__ = """
3030
The pyloggermanager.handlers package provides classes responsible for handling log records
31-
generated within the logger manager framework. It includes various handlers for processing log
31+
generated within the logger manager framework. It includes various handlers for processing log
3232
messages, directing them to different destinations, and performing actions based on logging levels.
3333
3434
Below listed handler classes offer flexibility and customization options for managing log records
35-
within the logger manager framework. They enable users to define how log messages are processed,
35+
within the logger manager framework. They enable users to define how log messages are processed,
3636
where they are directed, and how they are formatted, catering to various logging scenarios and
3737
deployment environments.
3838

pyloggermanager/handlers/__main__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
self,
4545
name: str = None,
4646
level: int = 20,
47-
colorization: 'Colorization' = None,
47+
colorization=None,
4848
formatter: Formatter = DefaultFormatter()
4949
) -> None:
5050
"""
@@ -79,7 +79,7 @@ def __init__(
7979
self._release_lock()
8080

8181
@property
82-
def colorization(self) -> 'Colorization':
82+
def colorization(self):
8383
"""
8484
Gets the colorization object for the handler.
8585
@@ -88,7 +88,7 @@ def colorization(self) -> 'Colorization':
8888
return self._colorization
8989

9090
@colorization.setter
91-
def colorization(self, value: 'Colorization') -> None:
91+
def colorization(self, value) -> None:
9292
"""
9393
Sets the colorization object for the handler.
9494
@@ -199,7 +199,7 @@ def close(self) -> None:
199199
finally:
200200
self._release_lock()
201201

202-
def emit(self, record: 'Record', ignore_display: bool) -> None:
202+
def emit(self, record, ignore_display: bool) -> None:
203203
"""
204204
Abstract method to emit a log record.
205205
@@ -208,7 +208,7 @@ def emit(self, record: 'Record', ignore_display: bool) -> None:
208208
"""
209209
raise NotImplementedError('emit() method must be implemented in subclasses.')
210210

211-
def format(self, record: 'Record') -> str:
211+
def format(self, record) -> str:
212212
"""
213213
Formats a log record using the handler's formatter.
214214
@@ -232,7 +232,7 @@ def get_handlers() -> list[Any]:
232232
"""
233233
return _handlersList
234234

235-
def handle(self, record: 'Record', ignore_display: bool) -> None:
235+
def handle(self, record, ignore_display: bool) -> None:
236236
"""
237237
Handles a log record.
238238
@@ -262,7 +262,7 @@ def __init__(
262262
self,
263263
name: str = None,
264264
level: int = 20,
265-
colorization: 'Colorization' = None,
265+
colorization=None,
266266
formatter: Formatter = DefaultFormatter(),
267267
stream: Stream = TerminalStream()
268268
) -> None:
@@ -317,7 +317,7 @@ def close(self) -> None:
317317
self._stream.close()
318318
super().close()
319319

320-
def emit(self, record: 'Record', ignore_display: bool = True) -> None:
320+
def emit(self, record, ignore_display: bool = True) -> None:
321321
"""
322322
Emits the log record by formatting it, colorizing the message, and writing it to the stream.
323323
@@ -356,7 +356,7 @@ def __init__(
356356
self,
357357
name: str = None,
358358
level: int = 20,
359-
colorization: 'Colorization' = None,
359+
colorization=None,
360360
formatter: Formatter = DefaultFormatter(),
361361
stream: Stream = StdoutStream()
362362
) -> None:
@@ -416,7 +416,7 @@ def close(self) -> None:
416416
self._stream.close()
417417
super().close()
418418

419-
def emit(self, record: 'Record', ignore_display: bool) -> None:
419+
def emit(self, record, ignore_display: bool) -> None:
420420
"""
421421
Emits a log record to the stream.
422422
@@ -461,7 +461,7 @@ def __init__(
461461
self,
462462
name: str = None,
463463
level: int = 20,
464-
colorization: 'Colorization' = None,
464+
colorization=None,
465465
formatter: Formatter = DefaultFormatter(),
466466
file_name: str = 'default.log',
467467
file_mode: str = 'a',
@@ -596,7 +596,7 @@ def close(self) -> None:
596596
self._close_file_stream()
597597
super().close()
598598

599-
def emit(self, record: 'Record', ignore_display: bool) -> None:
599+
def emit(self, record, ignore_display: bool) -> None:
600600
"""
601601
Emits a log record by writing it to the log file.
602602

pyloggermanager/streams/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
can be directed to, allowing for flexible and customizable logging behaviour.
3232
3333
Below listed stream classes offer versatility in directing log messages to different output
34-
channels, allowing users to customize logging behavior based on their application's requirements
35-
and environment configuration. By supporting various stream types, the logger manager framework
36-
enables users to control where log records are displayed or stored, facilitating effective logging
34+
channels, allowing users to customize logging behavior based on their application's requirements
35+
and environment configuration. By supporting various stream types, the logger manager framework
36+
enables users to control where log records are displayed or stored, facilitating effective logging
3737
and troubleshooting processes.
3838
39-
Overall, the pyloggermanager.streams package enhances the functionality of the logger manager framework
39+
Overall, the pyloggermanager.streams package enhances the functionality of the logger manager framework
4040
by providing a range of stream classes for directing log messages to different output channels. Users can
41-
leverage these classes to tailor their logging setup to suit their specific needs and preferences, ensuring
41+
leverage these classes to tailor their logging setup to suit their specific needs and preferences, ensuring
4242
efficient management and processing of log records.
4343
"""
4444

pyloggermanager/textstyles/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
__name__ = "pyloggermanager.textstyles"
2727
__description__ = """
2828
The pyloggermanager.textstyles package provides utilities for defining and applying text styles
29-
to log messages within the logger manager framework. It includes classes for specifying text
30-
colors, background colors, and text effects, allowing users to customize the appearance of log
29+
to log messages within the logger manager framework. It includes classes for specifying text
30+
colors, background colors, and text effects, allowing users to customize the appearance of log
3131
messages according to their preferences.
3232
33-
This package is designed to enhance the visual representation of log messages by providing a
34-
flexible and intuitive way to apply various text styles. By incorporating these text styles
33+
This package is designed to enhance the visual representation of log messages by providing a
34+
flexible and intuitive way to apply various text styles. By incorporating these text styles
3535
into log messages, users can improve readability, emphasize important information, and differentiate
3636
between different types of log entries.
3737
38-
Overall, the pyloggermanager.textstyles package complements the logger manager framework by
39-
offering tools for creating visually appealing and informative log messages, contributing to a
38+
Overall, the pyloggermanager.textstyles package complements the logger manager framework by
39+
offering tools for creating visually appealing and informative log messages, contributing to a
4040
more effective logging experience.
4141
"""
4242

0 commit comments

Comments
 (0)