Skip to content

Commit 7ff643c

Browse files
authored
task: added linter (#44)
* Fix E501 line length issues in console.py, data.py, dictionary.py, exports.py, and file.py * Continue fixing E501 line length issues in imports.py * Fix E501 line length issues in table.py * Fix E501 line length issues in system.py * Fix E501 line length issues * Fixed remaining lint errors * fix: file download the pythonic way * chore: code cleaning * chore: code cleanup
1 parent 6568936 commit 7ff643c

34 files changed

Lines changed: 4147 additions & 1795 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ jobs:
2828
- name: Install dependencies
2929
run: uv sync --all-extras
3030

31+
- name: Run linting
32+
run: uv run ruff check .
33+
3134
- name: Run tests
3235
run: uv run pytest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ coverage
3232
__pycache__
3333

3434
debug.py
35-
.serena/
35+
.serena/
36+
plans/

.ruff.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Ruff configuration file
2+
3+
# Exclude a variety of commonly ignored directories.
4+
extend-exclude = [
5+
"__pycache__",
6+
".git",
7+
".venv",
8+
".eggs",
9+
".nox",
10+
".tox",
11+
".svn",
12+
".hg",
13+
"build",
14+
"dist",
15+
".mypy_cache",
16+
".pytest_cache",
17+
]
18+
19+
# Assume Python 3.10.
20+
target-version = "py310"
21+
22+
# Line length with preview to format
23+
line-length = 120
24+
preview = true
25+
26+
[lint]
27+
# Enable flake8-bugbear rules
28+
select = [
29+
"E", # pycodestyle errors
30+
"W", # pycodestyle warnings
31+
"F", # pyflakes
32+
"B", # flake8-bugbear
33+
"C4", # flake8-comprehensions
34+
"UP", # pyupgrade
35+
"SIM", # flake8-simplify
36+
]
37+
38+
# Allow autofix for all enabled rules (when `--fix`) is provided.
39+
fixable = ["ALL"]
40+
41+
42+
# Allow unused variables when underscore-prefixed.
43+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ install:
44
test:
55
uv run --all-extras pytest
66

7+
lint:
8+
uv run ruff check .
9+
10+
fix:
11+
uv run ruff check . --fix
12+
13+
format:
14+
uv run ruff format .
15+
16+
check: format fix
17+
718
build:
819
uv build
920

obiba_opal/__init__.py

Lines changed: 129 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,136 @@
1-
from obiba_opal.core import UriBuilder, OpalClient, OpalRequest, OpalResponse, Formatter, MagmaNameResolver, HTTPError
2-
from obiba_opal.project import ProjectService, BackupProjectCommand, RestoreProjectCommand
1+
from obiba_opal.core import (
2+
UriBuilder,
3+
OpalClient,
4+
OpalRequest,
5+
OpalResponse,
6+
Formatter,
7+
MagmaNameResolver,
8+
HTTPError,
9+
)
10+
from obiba_opal.project import (
11+
ProjectService,
12+
BackupProjectCommand,
13+
RestoreProjectCommand,
14+
)
315
from obiba_opal.table import CopyTableCommand, BackupViewService, RestoreViewService
4-
from obiba_opal.dictionary import DictionaryService, ExportAnnotationsService, ImportAnnotationsService
16+
from obiba_opal.dictionary import (
17+
DictionaryService,
18+
ExportAnnotationsService,
19+
ImportAnnotationsService,
20+
)
521
from obiba_opal.data import DataService, EntityService
622
from obiba_opal.analysis import AnalysisCommand, ExportAnalysisService
723
from obiba_opal.file import FileService
8-
from obiba_opal.exports import ExportPluginCommand, ExportCSVCommand, ExportXMLCommand, ExportRSASCommand, ExportRSPSSCommand, ExportRSTATACommand, ExportRDSCommand, ExportSQLCommand, ExportVCFCommand
24+
from obiba_opal.exports import (
25+
ExportPluginCommand,
26+
ExportCSVCommand,
27+
ExportXMLCommand,
28+
ExportRSASCommand,
29+
ExportRSPSSCommand,
30+
ExportRSTATACommand,
31+
ExportRDSCommand,
32+
ExportSQLCommand,
33+
ExportVCFCommand,
34+
)
935
from obiba_opal.subjects import UserService, GroupService
10-
from obiba_opal.perm import ProjectPermService, DatasourcePermService, TablePermService, VariablePermService, ResourcePermService, ResourcesPermService, RPermService, DataSHIELDPermService, SystemPermService
11-
from obiba_opal.imports import ImportPluginCommand, ImportCSVCommand, ImportIDMapService, ImportIDService, ImportLimeSurveyCommand, ImportOpalCommand, ImportRDSCommand, ImportRSASCommand, ImportRSPSSCommand, ImportRSTATACommand, ImportSQLCommand, ImportVCFCommand, ImportXMLCommand
12-
from obiba_opal.system import PluginService, SystemService, TaxonomyService, TaskService, RESTService
36+
from obiba_opal.perm import (
37+
ProjectPermService,
38+
DatasourcePermService,
39+
TablePermService,
40+
VariablePermService,
41+
ResourcePermService,
42+
ResourcesPermService,
43+
RPermService,
44+
DataSHIELDPermService,
45+
SystemPermService,
46+
)
47+
from obiba_opal.imports import (
48+
ImportPluginCommand,
49+
ImportCSVCommand,
50+
ImportIDMapService,
51+
ImportIDService,
52+
ImportLimeSurveyCommand,
53+
ImportOpalCommand,
54+
ImportRDSCommand,
55+
ImportRSASCommand,
56+
ImportRSPSSCommand,
57+
ImportRSTATACommand,
58+
ImportSQLCommand,
59+
ImportVCFCommand,
60+
ImportXMLCommand,
61+
)
62+
from obiba_opal.system import (
63+
PluginService,
64+
SystemService,
65+
TaxonomyService,
66+
TaskService,
67+
RESTService,
68+
)
1369
from obiba_opal.sql import SQLService, SQLHistoryService
1470
from obiba_opal.security import EncryptService, DecryptService
71+
72+
__all__ = [
73+
"UriBuilder",
74+
"OpalClient",
75+
"OpalRequest",
76+
"OpalResponse",
77+
"Formatter",
78+
"MagmaNameResolver",
79+
"HTTPError",
80+
"ProjectService",
81+
"BackupProjectCommand",
82+
"RestoreProjectCommand",
83+
"CopyTableCommand",
84+
"BackupViewService",
85+
"RestoreViewService",
86+
"DictionaryService",
87+
"ExportAnnotationsService",
88+
"ImportAnnotationsService",
89+
"DataService",
90+
"EntityService",
91+
"AnalysisCommand",
92+
"ExportAnalysisService",
93+
"FileService",
94+
"ExportPluginCommand",
95+
"ExportCSVCommand",
96+
"ExportXMLCommand",
97+
"ExportRSASCommand",
98+
"ExportRSPSSCommand",
99+
"ExportRSTATACommand",
100+
"ExportRDSCommand",
101+
"ExportSQLCommand",
102+
"ExportVCFCommand",
103+
"UserService",
104+
"GroupService",
105+
"ProjectPermService",
106+
"DatasourcePermService",
107+
"TablePermService",
108+
"VariablePermService",
109+
"ResourcePermService",
110+
"ResourcesPermService",
111+
"RPermService",
112+
"DataSHIELDPermService",
113+
"SystemPermService",
114+
"ImportPluginCommand",
115+
"ImportCSVCommand",
116+
"ImportIDMapService",
117+
"ImportIDService",
118+
"ImportLimeSurveyCommand",
119+
"ImportOpalCommand",
120+
"ImportRDSCommand",
121+
"ImportRSASCommand",
122+
"ImportRSPSSCommand",
123+
"ImportRSTATACommand",
124+
"ImportSQLCommand",
125+
"ImportVCFCommand",
126+
"ImportXMLCommand",
127+
"PluginService",
128+
"SystemService",
129+
"TaxonomyService",
130+
"TaskService",
131+
"RESTService",
132+
"SQLService",
133+
"SQLHistoryService",
134+
"EncryptService",
135+
"DecryptService",
136+
]

0 commit comments

Comments
 (0)