Skip to content

Commit

Permalink
Add ament_mypy unit test and export types (#95)
Browse files Browse the repository at this point in the history
* add ament_mypy unit test

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* skip docs

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* fixes conf.py

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

---------

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
  • Loading branch information
InvincibleRMC authored Aug 9, 2024
1 parent 186831a commit 1ef3b4c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ament_index_python/ament_index_python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def main(argv: List[str] = sys.argv[1:]) -> Optional[str]:
arg = parser.add_argument(
'resource_type', nargs='?', metavar='TYPE',
help='The type of the resource')
arg.completer = resource_type_completer
arg.completer = resource_type_completer # type: ignore[attr-defined]
arg = parser.add_argument(
'resource_name', nargs='?', metavar='NAME',
help='The name of the resource')
arg.completer = resource_name_completer
arg.completer = resource_name_completer # type: ignore[attr-defined]

try:
from argcomplete import autocomplete
Expand Down
8 changes: 5 additions & 3 deletions ament_index_python/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

# -- Imports -----------------------------------------------------
from typing import Dict, List, Sequence

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -82,7 +84,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
exclude_patterns: Sequence[str] = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
Expand All @@ -104,7 +106,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
html_static_path: List[str] = []

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand All @@ -125,7 +127,7 @@

# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
latex_elements: Dict[str, str] = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
Expand Down
1 change: 1 addition & 0 deletions ament_index_python/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_mypy</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
Expand Down
Empty file added ament_index_python/py.typed
Empty file.
20 changes: 20 additions & 0 deletions ament_index_python/test/test_mypy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_mypy.main import main


def test_mypy() -> None:
rc = main(argv=['--exclude', 'test'])
assert rc == 0, 'Found code style errors / warnings'

0 comments on commit 1ef3b4c

Please sign in to comment.