Solution#3606
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the main functional structure of the task is not yet correct, even though your variable definitions and sorted_variables dictionary are implemented properly. The core requirement for app/main.py is that it should only contain the 8 variable declarations and the sorted_variables dictionary; instead, it currently also includes test code, pytest/inspect imports, and even a self-import (import app.main), which is not part of the task and can cause recursion or context issues. To fix this, remove all test-related imports and functions from app/main.py, keeping only the variable declarations and the sorted_variables dictionary in that file (the provided tests/test_main.py already covers testing). The remaining issues reported by flake8 (missing type annotations, unused variable, line breaks, etc.) are style-related and will be guided by the linter, but they are secondary to the structural problem of mixing app and test code. Once app/main.py contains only the required variables and sorted_variables, and test logic is confined to the tests module, your solution will align with the task requirements. You did a solid job on the mutability classification and satisfying the dictionary structure, so you’re very close—just clean up the file structure as described.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| import pytest | ||
| import inspect | ||
| import app.main |
There was a problem hiding this comment.
This file should only contain your implementation (variable declarations and sorted_variables); pytest, inspect, and import app.main are test-related and belong in the tests module, not in app/main.py.
| # Тести | ||
| @pytest.mark.parametrize( | ||
| "variable_name", | ||
| [ | ||
| "lucky_number", | ||
| "pi", | ||
| "one_is_a_prime_number", | ||
| "name", | ||
| "my_favourite_films", | ||
| "profile_info", | ||
| "marks", | ||
| "collection_of_coins", | ||
| "sorted_variables", | ||
| ], | ||
| ) | ||
| def test_variables_should_be_defined(variable_name): | ||
| assert hasattr( | ||
| app.main, variable_name | ||
| ), f"Variable '{variable_name}' should be defined." | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "variable,value", | ||
| [ | ||
| ("lucky_number", 777), | ||
| ("pi", 3.14), | ||
| ("one_is_a_prime_number", False), | ||
| ("name", "Richard"), | ||
| ( | ||
| "my_favourite_films", | ||
| [ | ||
| "The Shawshank Redemption", | ||
| "The Lord of the Rings: The Return of the King", | ||
| "Pulp Fiction", | ||
| "The Good, the Bad and the Ugly", | ||
| "The Matrix", | ||
| ], | ||
| ), | ||
| ("profile_info", ("michel", "michel@gmail.com", "12345678")), | ||
| ("marks", {"John": 4, "Sergio": 3}), | ||
| ("collection_of_coins", {1, 2, 25}), | ||
| ], | ||
| ) | ||
| def test_variables_values(variable, value): | ||
| assert ( | ||
| getattr(app.main, variable) == value | ||
| ), f"Variable '{variable}' should be equal to {value}." | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "variable_name", | ||
| [ | ||
| "lucky_number", | ||
| "pi", | ||
| "one_is_a_prime_number", | ||
| "name", | ||
| "my_favourite_films", | ||
| "profile_info", | ||
| "marks", | ||
| "collection_of_coins", | ||
| ], | ||
| ) | ||
| def test_variables_should_be_added_to_sorted_variables(variable_name): | ||
| sorted_variables = getattr(app.main, "sorted_variables") | ||
| assert ( | ||
| getattr(app.main, variable_name) in sorted_variables["mutable"] or | ||
| getattr(app.main, variable_name) in sorted_variables["immutable"] | ||
| ), f"Variable '{variable_name}' should be added to 'sorted_variables'" | ||
|
|
||
|
|
||
| def is_immutable(obj): | ||
| if isinstance(obj, (int, str, bool, float, tuple)): | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| def test_variables_added_to_the_correct_list(): | ||
| sorted_variables = getattr(app.main, "sorted_variables") | ||
| for variable in sorted_variables["mutable"]: | ||
| assert is_immutable(variable) is False, ( | ||
| f"{variable} should be in 'immutable' list" | ||
| ) | ||
|
|
||
| for variable in sorted_variables["immutable"]: | ||
| assert is_immutable(variable) is True, ( | ||
| f"{variable} should be in 'mutable' list" | ||
| ) | ||
|
|
||
|
|
||
| def test_removed_comment(): | ||
| with open(app.main.__file__, "r") as f: | ||
| lines = inspect.getsource(app.main) | ||
| assert "# write your code here" not in lines No newline at end of file |
There was a problem hiding this comment.
The task only requires defining variables and the sorted_variables dictionary; from here down you have test code that duplicates what already exists in tests/test_main.py and should be removed from the main module.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because it fully meets the functional and structural requirements of the task. You have exactly 8 variables in app/main.py, each with a distinct data type (int, float, bool, str, list, tuple, dict, set), and your sorted_variables dictionary correctly separates mutable types (list, dict, set) from immutable types (int, float, bool, str, tuple) as required [CHECKLIST ITEMS #1–6]. All variables and sorted_variables are defined in the same main module, and app/main.py now only contains the variable declarations plus sorted_variables, with all test logic confined to tests/test_main.py [CHECKLIST ITEMS #8–10].
The only remaining issues are minor style problems flagged by flake8 in app/main.py (e.g., whitespace after [ on line 5 and under-indented continuation lines around lines 6–9), which are cosmetic and do not affect correctness or requirements compliance. You can fix these by removing extra spaces inside brackets and aligning continuation lines to the same indentation level for better PEP 8 compliance. Overall, your implementation is correct, clear, and aligned with the checklist—well done.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because it fully matches the task requirements: you defined exactly 8 variables in app/main.py, each with a distinct data type (int, float, bool, str, list, tuple, dict, set). You also created the sorted_variables dictionary in the same file, correctly grouping the mutable variables (my_favourite_films, marks, collection_of_coins) under the "mutable" key and the immutable ones (lucky_number, pi, one_is_a_prime_number, name, profile_info) under "immutable". The main module is clean and focused, containing only the variable declarations and sorted_variables, while all tests are correctly placed in tests/test_main.py, which aligns well with good separation-of-concerns practices.
Overall, your code is clear, minimal, and easy to read, without extra unused variables or logic. This is a solid implementation that demonstrates a good understanding of Python data types and mutability concepts. Well done, and keep building on this clean, organized style in future exercises.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.