Skip to content

Commit e10a4b9

Browse files
committed
feat:: configure ruff and reformat all files
1 parent c9231ba commit e10a4b9

File tree

98 files changed

+2629
-1934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2629
-1934
lines changed

.codeclimate.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ checks:
4343
threshold: #language-specific defaults. overrides affect all languages.
4444

4545
plugins:
46-
eslint:
47-
enabled: true
48-
channel: "eslint-6"
46+
# ESLint disabled - Python project only
4947

5048
exclude_patterns:
5149
- "dist/"

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ jobs:
2222
pip install -r requirements.txt
2323
pip install -r requirements_dev.txt
2424
python -m spacy download en_core_web_md
25-
- name: Lint with flake8
25+
- name: Lint and format check with ruff
2626
run: |
27-
flake8 . --count --max-complexity=10 --max-line-length=121 --show-source --statistics
27+
ruff check .
28+
ruff format --check .
2829
- name: Test with pytest and coverage
2930
env:
3031
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ v3.7.1
77
*Release date: In development*
88

99
- Add pyproject.toml file for packaging and publishing Toolium
10+
- Configure ruff for linting and formatting files, replacing flake8 and black
1011
- Add text analysis tool to get an overall match of a text against a list of expected characteristics
1112
using AI libraries that come with the `ai` extra dependency
1213

README.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,27 @@ Contributing
6969
If you want to collaborate in Toolium development, feel free of `forking it <https://github.com/Telefonica/toolium>`_
7070
and asking for a pull request.
7171

72-
Don't forget to run unit tests:
72+
Installing and setting up the development environment is quite easy, just clone the repository and install the dependencies in your virtualenv:
7373

7474
.. code:: console
7575
7676
$ git clone git@github.com:<your_github_user>/toolium.git
7777
$ cd toolium
7878
$ pip install -r requirements.txt
7979
$ pip install -r requirements_dev.txt
80+
81+
Before submitting your changes, make sure the code follows the project's style by running Ruff:
82+
83+
.. code:: console
84+
85+
$ ruff check . # Check for linting issues
86+
$ ruff check --fix . # Fix auto-fixable issues
87+
$ ruff format . # Format code
88+
89+
Then run the unit tests:
90+
91+
.. code:: console
92+
8093
$ python -m pytest
8194
8295
Finally, before accepting your contribution, we need you to sign our

docs/ai_utils.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ achieve at least 80% accuracy.
158158
@accuracy_80_10
159159
Scenario: Validate AI-generated response accuracy
160160
Given the AI model generates a response
161-
When the user sends a message
162-
Then the AI response should be accurate
161+
When the user sends a message
162+
Then the AI response should be accurate
163163
164164
When a scenario is tagged with an accuracy tag, Toolium will automatically execute the scenario multiple times. If the
165165
scenario does not meet the specified accuracy after the given number of executions, it will be marked as failed.
@@ -187,8 +187,8 @@ accuracy data set with the suffix "greetings".
187187
@accuracy_data_greetings
188188
Scenario: Validate AI-generated greeting responses
189189
Given the AI model generates a greeting response
190-
When the user sends "[CONTEXT:accuracy_execution_data.question]" message
191-
Then the AI greeting response should be similar to "[CONTEXT:accuracy_execution_data.answer]"
190+
When the user sends "[CONTEXT:accuracy_execution_data.question]" message
191+
Then the AI greeting response should be similar to "[CONTEXT:accuracy_execution_data.answer]"
192192
193193
When a scenario is tagged with an accuracy data tag, Toolium will automatically use the specified accuracy data set for
194194
each execution. This allows you to test different scenarios with varying data inputs. Accuracy data should be stored

docs/bdd_integration.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,27 @@ Example::
114114

115115
Actions Before the Feature:
116116
Given wait 3 seconds
117-
And waitrty 3 seconds
118-
And wait 3 seconds
119-
And step with a table
120-
| parameter | value |
121-
| sub_fields_1 | sub_value 1 |
122-
| sub_fields_2 | sub_value 2 |
117+
And waitrty 3 seconds
118+
And wait 3 seconds
119+
And step with a table
120+
| parameter | value |
121+
| sub_fields_1 | sub_value 1 |
122+
| sub_fields_2 | sub_value 2 |
123123

124124
Actions Before each Scenario:
125125
Given the user navigates to the "www.google.es" url
126-
When the user logs in with username and password
127-
And wait 1 seconds
128-
And wait 1 seconds
126+
When the user logs in with username and password
127+
And wait 1 seconds
128+
And wait 1 seconds
129129

130130
Actions After each Scenario:
131-
And wait 2 seconds
132-
And wait 2 seconds
131+
Then wait 2 seconds
132+
And wait 2 seconds
133133

134134
Actions After the Feature:
135-
And wait 4 seconds
136-
And step with another step executed dynamically
137-
And wait 4 seconds
135+
Then wait 4 seconds
136+
And step with another step executed dynamically
137+
And wait 4 seconds
138138

139139

140140
All kind of steps are allowed:

docs/conf.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
@@ -72,7 +71,7 @@
7271

7372
# General information about the project.
7473
project = 'Toolium'
75-
copyright = '2015-2021, Telefónica I+D'
74+
copyright = '2015-2026, Telefónica I+D' # noqa: A001
7675

7776
# The version info for the project you're documenting, acts as replacement for
7877
# |version| and |release|, also used in various other places throughout the
@@ -81,9 +80,9 @@
8180
# The short X.Y version.
8281
version = open('../VERSION').read().strip()
8382
# The full version, including alpha/beta/rc tags.
84-
git_log = subprocess.check_output(["git", "log", "--pretty=oneline"])
83+
git_log = subprocess.check_output(['git', 'log', '--pretty=oneline'])
8584
commits = git_log.split(b'\n')
86-
release = '{}-{}'.format(version, len(commits) - 1)
85+
release = f'{version}-{len(commits) - 1}'
8786

8887
# The language for content autogenerated by Sphinx. Refer to documentation
8988
# for a list of supported languages.
@@ -129,7 +128,7 @@
129128
# The theme to use for HTML and HTML Help pages. See the documentation for
130129
# a list of builtin themes.
131130
# html_theme = 'default'
132-
html_theme = "sphinx_rtd_theme"
131+
html_theme = 'sphinx_rtd_theme'
133132

134133
# Theme options are theme-specific and customize the look and feel of a theme
135134
# further. For a list of options available for each theme, see the
@@ -214,10 +213,8 @@
214213
latex_elements = {
215214
# The paper size ('letterpaper' or 'a4paper').
216215
# 'papersize': 'letterpaper',
217-
218216
# The font size ('10pt', '11pt' or '12pt').
219217
# 'pointsize': '10pt',
220-
221218
# Additional stuff for the LaTeX preamble.
222219
# 'preamble': '',
223220
}
@@ -255,7 +252,7 @@
255252
# One entry per manual page. List of tuples
256253
# (source start file, name, description, authors, manual section).
257254
man_pages = [
258-
('index', 'Toolium', 'Toolium Documentation', ['Rubén González Alonso, Telefónica I+D'], 1)
255+
('index', 'Toolium', 'Toolium Documentation', ['Rubén González Alonso, Telefónica I+D'], 1),
259256
]
260257

261258
# If true, show URL addresses after external links.
@@ -268,9 +265,15 @@
268265
# (source start file, target name, title, author,
269266
# dir menu entry, description, category)
270267
texinfo_documents = [
271-
('index', 'Toolium', 'toolium Documentation', 'Rubén González Alonso, Telefónica I+D', 'toolium',
272-
'Wrapper tool of Selenium and Appium libraries to test web and mobile applications in a single project.',
273-
'Miscellaneous'),
268+
(
269+
'index',
270+
'Toolium',
271+
'toolium Documentation',
272+
'Rubén González Alonso, Telefónica I+D',
273+
'toolium',
274+
'Wrapper tool of Selenium and Appium libraries to test web and mobile applications in a single project.',
275+
'Miscellaneous',
276+
),
274277
]
275278

276279
# Documents to append as an appendix to all manuals.
@@ -291,9 +294,9 @@
291294

292295
def remove_module_docstring(app, what, name, obj, options, lines):
293296
"""Remove all module docstrings to exclude license header"""
294-
if what == "module":
297+
if what == 'module':
295298
del lines[:]
296299

297300

298301
def setup(app):
299-
app.connect("autodoc-process-docstring", remove_module_docstring)
302+
app.connect('autodoc-process-docstring', remove_module_docstring)

pyproject.toml

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -105,50 +105,43 @@ exclude_lines = [
105105
"if __name__ == .__main__.:",
106106
]
107107

108-
[tool.black]
109-
line-length = 120
110-
target-version = ['py310', 'py311', 'py312', 'py313']
111-
include = '\.pyi?$'
112-
extend-exclude = '''
113-
/(
114-
# directories
115-
\.eggs
116-
| \.git
117-
| \.hg
118-
| \.mypy_cache
119-
| \.tox
120-
| \.venv
121-
| build
122-
| dist
123-
)/
124-
'''
125-
126-
[tool.isort]
127-
profile = "black"
128-
line_length = 120
129-
multi_line_output = 3
130-
include_trailing_comma = true
131-
force_grid_wrap = 0
132-
use_parentheses = true
133-
ensure_newline_before_comments = true
134-
135108
[tool.ruff]
136109
line-length = 120
137110
target-version = "py310"
111+
112+
[tool.ruff.lint]
113+
# Rules to enforce
138114
select = [
139-
"E", # pycodestyle errors
140-
"W", # pycodestyle warnings
141-
"F", # pyflakes
142-
"I", # isort
143-
"B", # flake8-bugbear
144-
"C4", # flake8-comprehensions
145-
"UP", # pyupgrade
115+
"E", # pycodestyle errors
116+
"W", # pycodestyle warnings
117+
"F", # Pyflakes
118+
"I", # isort
119+
"UP", # pyupgrade
120+
"N", # pep8-naming
121+
"B", # flake8-bugbear
122+
"A", # flake8-builtins
123+
"COM", # flake8-commas
124+
"C4", # flake8-comprehensions
125+
"PT", # flake8-pytest-style
126+
"RUF", # Ruff-specific rules
146127
]
147-
ignore = [
148-
"E501", # line too long, handled by black
149-
"B008", # do not perform function calls in argument defaults
150-
"C901", # too complex
128+
# Rules to ignore
129+
ignore = []
130+
131+
[tool.ruff.lint.isort]
132+
combine-as-imports = true
133+
split-on-trailing-comma = true
134+
known-first-party = ["acceptance"]
135+
section-order = [
136+
"future",
137+
"standard-library",
138+
"third-party",
139+
"first-party",
140+
"local-folder"
151141
]
152142

153-
[tool.ruff.per-file-ignores]
154-
"__init__.py" = ["F401"]
143+
[tool.ruff.format]
144+
quote-style = "single"
145+
indent-style = "space"
146+
skip-magic-trailing-comma = false
147+
line-ending = "auto"

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ coveralls~=4.0
44
mock~=5.0
55
requests-mock~=1.10
66
Pygments~=2.14
7-
flake8~=7.3
87
build~=1.3
98
wheel~=0.40
109
twine~=6.2
@@ -13,3 +12,4 @@ importlib_metadata~=8.7
1312
spacy~=3.8
1413
sentence-transformers~=5.1
1514
openai~=2.7
15+
ruff~=0.15

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
43
This file is part of Toolium.
@@ -15,6 +14,7 @@
1514
See the License for the specific language governing permissions and
1615
limitations under the License.
1716
"""
17+
1818
from setuptools import setup
1919

2020
setup()

0 commit comments

Comments
 (0)