Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff rule F601 - Dictionary key literal 'use_composition' repeated #4293

Merged
merged 1 commit into from
May 3, 2024

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented May 3, 2024

% ruff check

Error: nav2_system_tests/src/system/test_wrong_init_pose_launch.py:117:21:
  F601 Dictionary key literal `'use_composition'` repeated

% ruff rule F601

multi-value-repeated-key-literal (F601)

Derived from the Pyflakes linter.

Fix is sometimes available.

What it does

Checks for dictionary literals that associate multiple values with the same key.

Why is this bad?

Dictionary keys should be unique. If a key is associated with multiple values, the earlier values will be overwritten. Including multiple values for the same key in a dictionary literal is likely a mistake.

Example

foo = {
    "bar": 1,
    "baz": 2,
    "baz": 3,
}
foo["baz"]  # 3

Use instead:

foo = {
    "bar": 1,
    "baz": 2,
}
foo["baz"]  # 2

References


Basic Info

Info Please fill out this column
Ticket(s) this addresses (add tickets here #1)
Primary OS tested on (Ubuntu, MacOS, Windows)
Robotic platform tested on (Steve's Robot, gazebo simulation of Tally, hardware turtlebot)
Does this PR contain AI generated software? (No; Yes and it is marked inline in the code)

Description of contribution in a few bullet points

Description of documentation updates required from your changes


Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in navigation.ros.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

% `ruff check`
```
Error: nav2_system_tests/src/system/test_wrong_init_pose_launch.py:117:21: F601 Dictionary key literal `'use_composition'` repeated
```
% ` ruff rule F601`
# multi-value-repeated-key-literal (F601)

Derived from the **Pyflakes** linter.

Fix is sometimes available.

## What it does
Checks for dictionary literals that associate multiple values with the
same key.

## Why is this bad?
Dictionary keys should be unique. If a key is associated with multiple values,
the earlier values will be overwritten. Including multiple values for the
same key in a dictionary literal is likely a mistake.

## Example
```python
foo = {
    "bar": 1,
    "baz": 2,
    "baz": 3,
}
foo["baz"]  # 3
```

Use instead:
```python
foo = {
    "bar": 1,
    "baz": 2,
}
foo["baz"]  # 2
```

## References
- [Python documentation: Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)


Signed-off-by: Christian Clauss <[email protected]>
Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :-)

@SteveMacenski SteveMacenski merged commit 329875a into ros-navigation:main May 3, 2024
8 of 9 checks passed
@cclauss cclauss deleted the patch-1 branch May 3, 2024 16:45
enricosutera pushed a commit to enricosutera/navigation2 that referenced this pull request May 19, 2024
…os-navigation#4293)

% `ruff check`
```
Error: nav2_system_tests/src/system/test_wrong_init_pose_launch.py:117:21: F601 Dictionary key literal `'use_composition'` repeated
```
% ` ruff rule F601`
# multi-value-repeated-key-literal (F601)

Derived from the **Pyflakes** linter.

Fix is sometimes available.

## What it does
Checks for dictionary literals that associate multiple values with the
same key.

## Why is this bad?
Dictionary keys should be unique. If a key is associated with multiple values,
the earlier values will be overwritten. Including multiple values for the
same key in a dictionary literal is likely a mistake.

## Example
```python
foo = {
    "bar": 1,
    "baz": 2,
    "baz": 3,
}
foo["baz"]  # 3
```

Use instead:
```python
foo = {
    "bar": 1,
    "baz": 2,
}
foo["baz"]  # 2
```

## References
- [Python documentation: Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)

Signed-off-by: Christian Clauss <[email protected]>
Signed-off-by: enricosutera <[email protected]>
Marc-Morcos pushed a commit to Marc-Morcos/navigation2 that referenced this pull request Jul 4, 2024
…os-navigation#4293)

% `ruff check`
```
Error: nav2_system_tests/src/system/test_wrong_init_pose_launch.py:117:21: F601 Dictionary key literal `'use_composition'` repeated
```
% ` ruff rule F601`
# multi-value-repeated-key-literal (F601)

Derived from the **Pyflakes** linter.

Fix is sometimes available.

## What it does
Checks for dictionary literals that associate multiple values with the
same key.

## Why is this bad?
Dictionary keys should be unique. If a key is associated with multiple values,
the earlier values will be overwritten. Including multiple values for the
same key in a dictionary literal is likely a mistake.

## Example
```python
foo = {
    "bar": 1,
    "baz": 2,
    "baz": 3,
}
foo["baz"]  # 3
```

Use instead:
```python
foo = {
    "bar": 1,
    "baz": 2,
}
foo["baz"]  # 2
```

## References
- [Python documentation: Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)

Signed-off-by: Christian Clauss <[email protected]>
Manos-G pushed a commit to Manos-G/navigation2 that referenced this pull request Aug 1, 2024
…os-navigation#4293)

% `ruff check`
```
Error: nav2_system_tests/src/system/test_wrong_init_pose_launch.py:117:21: F601 Dictionary key literal `'use_composition'` repeated
```
% ` ruff rule F601`
# multi-value-repeated-key-literal (F601)

Derived from the **Pyflakes** linter.

Fix is sometimes available.

## What it does
Checks for dictionary literals that associate multiple values with the
same key.

## Why is this bad?
Dictionary keys should be unique. If a key is associated with multiple values,
the earlier values will be overwritten. Including multiple values for the
same key in a dictionary literal is likely a mistake.

## Example
```python
foo = {
    "bar": 1,
    "baz": 2,
    "baz": 3,
}
foo["baz"]  # 3
```

Use instead:
```python
foo = {
    "bar": 1,
    "baz": 2,
}
foo["baz"]  # 2
```

## References
- [Python documentation: Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)

Signed-off-by: Christian Clauss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants