ronantakizawa/codereview-bench huggingface dataset:
Repository: Avaiga/taipy
File: taipy/core/common/_check_dependencies.py (Python)

Code before:
# 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 importlib import util


def _check_dependency_is_installed(module_name: str, package_name: str) -> None:
    """
        Check if a package is installed.

        Args:
            module_name: Name of the taipy module importing the package.
            package_name: Name of the package.
    .
    """
    extras = {
        "boto3": "s3",
        "pymongo": "mongo",
    }
    if not util.find_spec(package_name):
        raise RuntimeError(
            f"Cannot use {module_name} as {package_name} package is not installed. Please install it  "
            f"using `pip install taipy[{extras.get(package_name)}]`."
        )


class EnterpriseChecker:
    _TAIPY_ENTERPRISE_MODULE = "taipy.enterprise"
    _TAIPY_ENTERPRISE_CORE_MODULE = _TAIPY_ENTERPRISE_MODULE + ".core"

    @classmethod
    def _using_enterprise(cls) -> bool:
        return util.find_spec(cls._TAIPY_ENTERPRISE_MODULE) is not None


Review comment (refactor):
The official name is Enterprise Edition. Plus Checker is used in another context, to verify the consistency of config sections. I would propose the following names:
- EnterpriseEditionHelper
- EnterpriseEditionUtils
- EnterpriseEditionContext

What do you think?


Code after:
# 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 importlib import util


def _check_dependency_is_installed(module_name: str, package_name: str) -> None:
    """
        Check if a package is installed.

        Args:
            module_name: Name of the taipy module importing the package.
            package_name: Name of the package.
    .
    """
    extras = {
        "boto3": "s3",
        "pymongo": "mongo",
    }
    if not util.find_spec(package_name):
        raise RuntimeError(
            f"Cannot use {module_name} as {package_name} package is not installed. Please install it  "
            f"using `pip install taipy[{extras.get(package_name)}]`."
        )


class EnterpriseEditionUtils:
    _TAIPY_ENTERPRISE_MODULE = "taipy.enterprise"
    _TAIPY_ENTERPRISE_CORE_MODULE = _TAIPY_ENTERPRISE_MODULE + ".core"

    @classmethod
    def _using_enterprise(cls) -> bool:
        return util.find_spec(cls._TAIPY_ENTERPRISE_MODULE) is not None
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_active.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

init_value = 20

page = """
Input field has been disabled: <|{init_value}|input|active=false|>
"""

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


Review comment (suggestion):
```suggestion
<|{value}|input|active=false|>
```
Simpler 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

value = 20

page = """
<|{value}|input|active=false|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Input - Inactive")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_active.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

init_value = 20

page = """
Input field has been disabled: <|{init_value}|input|active=false|>
"""

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


Review comment (suggestion):
```suggestion
value = 20
```
Not 'init' for very long, normally...

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

value = 20

page = """
<|{value}|input|active=false|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Input - Inactive")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_active.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

init_value = 20

page = """
Input field has been disabled: <|{init_value}|input|active=false|>
"""

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


Review comment (suggestion):
```suggestion
    Gui(page).run(title="Input - Inactive")
```
That's new, from Fred. But I kind of like it.

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

value = 20

page = """
<|{value}|input|active=false|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Input - Inactive")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_change_delay_on_change.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, format='%(asctime)s - %(levelname)s - %(message)s')

INIT_VALUE = ""


def on_change(state, var_name, value):
    logging.info(f"Value of {var_name} changed to {value}")


# If change_delay is set to -1, the change event is triggered on Enter key press
page = """
Enter a number (changes triggered on Enter key press): <|{INIT_VALUE}|input|change_delay=-1|on_change=on_change|>
"""


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


Review comment (suggestion):
```suggestion
<|{value}|input|change_delay=-1|>
```

And add a little paragraph on the on_change setting:
"The [*on_change*][#p-on_change] property is not set: Taipy GUI automatically finds and binds the global *on_change()* function to handle changes in the input control. You could set this property to your own function if necessary."

Code after:
#
# 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, format='%(asctime)s - %(levelname)s - %(message)s')

value = ""


# The [on_change] property is not set: Taipy GUI automatically finds and binds the global on_change()
# function to handle changes in the input control. You could set this property to your own function if necessary.
def on_change(state, var_name, v):
    logging.info(f"Value of {var_name} changed to {v}")


# If change_delay is set to -1, the change event is triggered on Enter key press
page = """
<|{value}|input|change_delay=-1|>
"""


if __name__ == "__main__":
    Gui(page).run(title="Input - on_change")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_change_delay_on_change.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, format='%(asctime)s - %(levelname)s - %(message)s')

INIT_VALUE = ""


def on_change(state, var_name, value):
    logging.info(f"Value of {var_name} changed to {value}")


# If change_delay is set to -1, the change event is triggered on Enter key press
page = """
Enter a number (changes triggered on Enter key press): <|{INIT_VALUE}|input|change_delay=-1|on_change=on_change|>
"""


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


Review comment (suggestion):
```suggestion
    Gui(page).run(title="input - on_change")
```

Code after:
# 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, format='%(asctime)s - %(levelname)s - %(message)s')

value = ""


# The [on_change] property is not set: Taipy GUI automatically finds and binds the global on_change()
# function to handle changes in the input control. You could set this property to your own function if necessary.
def on_change(state, var_name, v):
    logging.info(f"Value of {var_name} changed to {v}")


# If change_delay is set to -1, the change event is triggered on Enter key press
page = """
<|{value}|input|change_delay=-1|>
"""


if __name__ == "__main__":
    Gui(page).run(title="Input - on_change")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_line_shown.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

numbered_lines = "1 \n2 \n3 \n4 \n5"

page = """
Multi-line input: <|{numbered_lines}|input|multiline|lines_shown=5|>
"""

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


Review comment (suggestion):
```suggestion
<|{lines}|input|multiline|lines_shown=5|>
```

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

lines = "1 \n2 \n3 \n4 \n5"

page = """
<|{lines}|input|multiline|lines_shown=5|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Input - Lines shown")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_line_shown.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

numbered_lines = "1 \n2 \n3 \n4 \n5"

page = """
Multi-line input: <|{numbered_lines}|input|multiline|lines_shown=5|>
"""

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


Review comment (suggestion):
```suggestion
    Gui(page).run(title="input - Lines shown")
```

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

lines = "1 \n2 \n3 \n4 \n5"

page = """
<|{lines}|input|multiline|lines_shown=5|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Input - Lines shown")
Repository: Avaiga/taipy
File: doc/gui/examples/controls/input_multiline.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

LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec purus et nunc lacinia gravida. " \


page = """
Multi-line input: <|{LOREM_IPSUM}|input|multiline|>
"""

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


Review comment (suggestion):
```suggestion
    Gui(page).run(title="input - Multiline")
```

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

text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec purus et nunc lacinia gravida. "


page = """
<|{text}|input|multiline|>
"""

if __name__ == "__main__":
    Gui(page).run(title="Input - Multiline")