Skip to content

Commit 4ce8124

Browse files
Create pylint.yml (#13)
Support pylint in CI
1 parent 500c72c commit 4ce8124

File tree

9 files changed

+58
-17
lines changed

9 files changed

+58
-17
lines changed

.github/workflows/pylint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pylint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.12"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install pylint
21+
- name: Analysing the code with pylint
22+
run: |
23+
pylint .

.pylintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[MAIN]
2+
ignore=venv
3+
4+
[MESSAGES CONTROL]
5+
disable=
6+
C0114, # missing-module-docstring
7+
C0115, # missing-class-docstring
8+
C0116, # missing-function-docstring
9+
C0301, # line-too-long
10+
E0401, # import-error
11+
R0903, # too-few-public-methods
12+
R0913, # too-many-arguments
13+
R0917, # too-many-positional-arguments
14+
R0801, # duplicate-code
15+
W1203, # logging-fstring-interpolation
16+
W0511, # fixme
17+
18+
[REPORTS]
19+
reports=no

mind/generator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def gen_all_mindmaps(markdown_content, file_name, only_what):
1515
md_name = output_name + ".md"
1616
mm_name = output_name + ".mm"
1717
svg_name = output_name
18-
18+
1919
match only_what:
2020
case 0:
2121
generate_md(markdown_content, md_name)
@@ -27,4 +27,3 @@ def gen_all_mindmaps(markdown_content, file_name, only_what):
2727
generate_freemind(markdown_content, mm_name)
2828
case 3:
2929
generate_svg(markdown_content, svg_name)
30-

mind/mm_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def generate_freemind(md_text, output_file="freemind-output.mm"):
5454
for item in tree_data:
5555
build_freemind_node(root, item)
5656
tree = ET.ElementTree(root)
57-
57+
5858
try:
59-
with open(output_file, 'w', encoding='utf-8') as file:
59+
with open(output_file, 'w', encoding='utf-8'):
6060
tree.write(output_file, encoding="utf-8", xml_declaration=True)
6161
logger.info(f"✅ The freemind mind map has been successfully generated: {output_file}")
6262
except IOError:

mind/svg_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def tree_to_svg(nodes, output_file="mindmap"):
5959
dot.edge(node["parent"], node_id)
6060
dot.render(output_file, view=False)
6161

62-
def generate_svg(md_text, output_file="mindmap"):
62+
def generate_svg(md_text, output_file="mindmap"):
6363
tree = parse_markdown(md_text)
6464
# TODO try catch here
6565
tree_to_svg(tree, output_file)

pdf/pdf_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def extract_and_feed_chunks(self, args, queue: asyncio.Queue):
2525
pdf_name = str(args.pdf)
2626
chunk_size = getattr(args, 'chunk_size', None)
2727
overlap_size = getattr(args, 'overlap_size', None)
28-
28+
2929
kwargs = {}
3030
if chunk_size is not None:
3131
kwargs['chunk_size'] = int(chunk_size)

pdf2mind.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import asyncio
2-
from utils.parser import cmd_parser
2+
33
from pdf.pdf_reader import PdfProcess
44
from mind.generator import gen_all_mindmaps
5+
from utils.parser import cmd_parser
56
from utils.utils import model_selector, format_selector
67

78

utils/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def cmd_parser():
5858
# Should not happen due to required=True
5959
vender = "Unknown"
6060

61-
if not llm_key:
61+
if not llm_key: # pylint: disable=possibly-used-before-assignment
6262
logger.info("Error: LLM API Key is required. Please provide it via --key argument or set the XXX_API_KEY environment variable.")
6363
sys.exit(1)
6464

@@ -67,6 +67,6 @@ def cmd_parser():
6767
logger.info(f"🌍 Target language: {language}")
6868
logger.info(f"🧠 Selected vender: {vender}")
6969
logger.info(f"🤖 Model name: {model}\n")
70-
70+
7171
args = parser.parse_args()
7272
return args

utils/utils.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
from llm.base_llm import BaseLLM
32
from llm.doubao_llm import DoubaoLLM
4-
from llm.qwen_llm import QwenLLM
53
from llm.openai_llm import OpenaiLLM
4+
from llm.qwen_llm import QwenLLM
65

76
def model_selector(args) -> BaseLLM:
87
# set default
@@ -11,19 +10,19 @@ def model_selector(args) -> BaseLLM:
1110

1211
if getattr(args, 'use_doubao', False):
1312
return DoubaoLLM(args.model, args.language, max_level, temperature)
14-
elif getattr(args, 'use_qwen', False):
13+
if getattr(args, 'use_qwen', False):
1514
return QwenLLM(args.model, args.language, max_level, temperature)
16-
elif getattr(args, 'use_openai', False):
15+
if getattr(args, 'use_openai', False):
1716
return OpenaiLLM(args.model, args.language, max_level, temperature)
18-
else:
19-
raise ValueError("Please at least set one of --use-doubao、--use-qwen or --use-openai")
17+
18+
raise ValueError("Please at least set one of --use-doubao、--use-qwen or --use-openai")
2019

2120
def format_selector(args) -> int:
2221
if args.only_freemind:
2322
return 1
24-
elif args.only_xmind:
23+
if args.only_xmind:
2524
return 2
26-
elif args.only_svg:
25+
if args.only_svg:
2726
return 3
2827
return 0
2928

0 commit comments

Comments
 (0)