ronantakizawa/codereview-bench huggingface dataset:
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_inactive.py (Python)

Code before:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]


md = """
<|menu|lov={lov}|active=False|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
```
Shorter is better

Code after:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]


page = """
<|menu|lov={options}|not active|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - Inactive")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
```

Code after:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
    Gui(page).run(title="Menu - Action")
```

Code after:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
<|menu|lov={options}|on_action=menu_action|>
```

Code after:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
def menu_action(_1, _2, payload)
```

Code after:
# Copyright 2021-2024 Avaiga Private Limited
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
    selected_options = payload["args"]
```

Code after:
#
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
    for option in selected_options:
```

Code after:
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/menu_on_action.py (Python)

Code before:
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
import logging

from taipy.gui import Gui

# Configure logging
logging.basicConfig(level=logging.INFO)

lov = [("id1", "Menu option 1"), ("id2", "Menu option 2"), ("id3", "Menu option 3"), ("id4", "Menu option 4")]
selected_ids = ["id1", "id2"]

def menu_action(state, id, payload):
    active = payload.get("args")
    for i in active:
        logging.info(f"Menu option {i} selected")

md = """
<|menu|lov={lov}|selected_ids={selected_ids}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(md).run()


Review comment (suggestion):
```suggestion
        print(f"Menu option {option} selected")  # noqa: F401, T201
```

Code after:
# 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.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
#     python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

options = [("a", "Option A"), ("b", "Option B"), ("c", "Option C"), ("d", "Option D")]
selected = ["a", "b"]

def menu_action(state, id, payload):
    if payload.get("args")[0] in state.selected:
        print(f"Option {payload.get('args')[0]} is already selected") # noqa: F401, T201

page = """
<|menu|lov={options}|selected={selected}|on_action=menu_action|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Menu - On Action")