Skip to content

Commit 85be031

Browse files
Suggestion to add ament_ruff.
1 parent bd2e639 commit 85be031

File tree

12 files changed

+197
-0
lines changed

12 files changed

+197
-0
lines changed

ament_ruff/CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2+
Changelog for package ament_ruff
3+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ament_ruff/ament_ruff/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[lint]
2+
select =["ALL"]
3+
ignore = ["D100","D101","D102","D103","D104","D105","D106","D107","D203","D212","D404", "COM812"]
4+
[format]
5+
quote-style = "double"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[lint]
2+
select =["ALL"]
3+
[format]
4+
quote_style = "Double"

ament_ruff/ament_ruff/main.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2016 Open Source Robotics Foundation, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import sys
18+
19+
import subprocess
20+
21+
def main(argv=sys.argv[1:]):
22+
result = subprocess.run(
23+
[
24+
"ruff",
25+
"format",
26+
"--config",
27+
"/opt/overlay_ws/src/navigation2/ament_lint/ament_ruff/ament_ruff/ament_ruff.toml",
28+
],
29+
capture_output=True,
30+
text=True,
31+
)
32+
lint_result = subprocess.run(
33+
[
34+
"ruff",
35+
"check",
36+
"--config",
37+
"/opt/overlay_ws/src/navigation2/ament_lint/ament_ruff/ament_ruff/ament_ruff.toml",
38+
],
39+
capture_output=True,
40+
text=True,
41+
)
42+
sys.stdout.write(result.stdout)
43+
sys.stdout.write(lint_result.stdout)
44+
45+
46+
if __name__ == "__main__":
47+
sys.exit(main())
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2019 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
def pytest_configure(config):
17+
config.addinivalue_line(
18+
"markers", "ruff: marks tests checking for ruff compliance"
19+
)

ament_ruff/doc/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ament_ruff
2+
============
3+
4+
Checks the code syntax and style of Python source files using `ruff
5+
TODO: link to ruff`_.
6+
Files with the following extensions are being considered: ``.py``.
7+
8+
9+
How to run the check from the command line?
10+
-------------------------------------------
11+
12+
.. code:: sh
13+
14+
ament_ruff [<path> ...]
15+
16+
17+

ament_ruff/package.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="2">
4+
<name>ament_ruff</name>
5+
<version>0.19.1</version>
6+
<description>
7+
The ability to check code for style and syntax conventions and autoformat with ruff.
8+
</description>
9+
10+
<maintainer email=""></maintainer>
11+
12+
<license>Apache License 2.0</license>
13+
14+
<author email=""></author>
15+
<author email=""></author>
16+
<author></author>
17+
<author></author>
18+
<author email=""></author>
19+
20+
<exec_depend>ament_lint</exec_depend>
21+
<exec_depend>python3-ruff</exec_depend>
22+
23+
<export>
24+
<build_type>ament_python</build_type>
25+
</export>
26+
</package>

ament_ruff/pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
junit_family=xunit2

ament_ruff/resource/ament_ruff

Whitespace-only changes.

0 commit comments

Comments
 (0)