-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a title #1757
base: add_timeout
Are you sure you want to change the base?
Add a title #1757
Changes from all commits
e80085c
2392e6e
06d531d
5a44a08
7feed3f
b53c403
a07cd98
5eca31a
00e88af
2940476
d1b6594
c418a39
ee215a2
16d8349
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
[flake8] | ||
ignore = E203, E266 | ||
inline-quotes = " | ||
ignore = E203, E266, W503, ANN002, ANN003, ANN101, ANN102, ANN401, N807, N818 | ||
max-line-length = 79 | ||
max-complexity = 18 | ||
select = B,C,E,F,W,T4,B9 | ||
select = B,C,E,F,W,T4,B9,ANN,Q0,N8,VNE | ||
exclude = venv, tests |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Check Your Code Against the Following Points | ||
|
||
## Code Style | ||
|
||
1. If you have some long math, you can split it onto additional variables, | ||
or break after binary operations (not before - it cause the W504 errors) | ||
|
||
Good example: | ||
|
||
```python | ||
fuel_consumption = max_fuel_consumption * height_fuel_consumption_coeficient | ||
estimated_speed = plan_max_speed - wind_awerage_speed * wind_angle_coefisient | ||
estimated_time = distance_to_the_destinatoin / estimated_speed | ||
how_much_fuel_needed = fuel_consumption * estimated_time * overlap_coeficient | ||
``` | ||
|
||
Good example: | ||
|
||
```python | ||
how_much_fuel_needed = (max_fuel_consumption | ||
* height_fuel_consumption_coeficient | ||
* distance_to_the_destinatoin | ||
/ (plan_max_speed | ||
- wind_awerage_speed | ||
* wind_angle_coefisient) | ||
* overlap_coeficient) | ||
``` | ||
|
||
Bad example: | ||
|
||
```python | ||
how_much_fuel_needed = max_fuel_consumption \ | ||
* height_fuel_consumption_coeficient \ | ||
* distance_to_the_destinatoin / ( | ||
plan_max_speed | ||
- wind_awerage_speed | ||
* wind_angle_coefisient | ||
) * overlap_coeficient | ||
``` | ||
|
||
2. Use descriptive and correct variable names. | ||
|
||
Good example: | ||
|
||
```python | ||
def get_full_name(first_name: str, last_name: str) -> str: | ||
return f"{first_name} {last_name}" | ||
``` | ||
|
||
Bad example: | ||
```python | ||
def get_full_name(x: str, y: str) -> str: | ||
return f"{x} {y}" | ||
``` | ||
|
||
## Clean Code | ||
|
||
1. You can avoid else when have return statement. | ||
|
||
Good example: | ||
|
||
```python | ||
def is_adult(age: int) -> str: | ||
if age >= 18: | ||
return "adult" | ||
return "not an adult" | ||
``` | ||
|
||
Bad example: | ||
|
||
```python | ||
def is_adult(age: int) -> str: | ||
if age >= 18: | ||
return "adult" | ||
else: | ||
return "not an adult" | ||
``` | ||
|
||
2. Add comments, prints, and functions to check your solution when you write your code. | ||
Don't forget to delete them when you are ready to commit and push your code. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
pytest==6.2.5 | ||
flake8==4.0.1 | ||
flake8==5.0.4 | ||
flake8-annotations==2.9.1 | ||
flake8-quotes==3.3.1 | ||
flake8-variables-names==0.0.5 | ||
pep8-naming==0.13.2 | ||
pytest==7.1.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from unittest.mock import patch | ||
import pytest | ||
import os | ||
|
||
from app.main import Car, CarWashStation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the |
||
|
||
|
@@ -37,6 +39,12 @@ def test_car_wash_station(cars, wash_station, total_cost): | |
income = wash_station.serve_cars(cars) | ||
assert income == total_cost, f"Income should equal to {total_cost}" | ||
|
||
def test_wash_single_car_is_called(): | ||
with patch.object(CarWashStation, 'wash_single_car') as mock_method: | ||
CarWashStation(3, 9, 4, 11).serve_cars([Car(2, 1, "Ford")]) | ||
ProgrammerYaroslav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert mock_method.called, "Expected 'wash_single_car' to have " \ | ||
"been called inside 'serve_cars' method" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"cars,wash_station,cars_clean_marks", | ||
|
@@ -101,3 +109,17 @@ def test_rate_service( | |
f"'count_of_ratings' should equal to {result_num_ratings}, " | ||
f"when initial 'count_of_ratings' was {init_num_ratings}" | ||
) | ||
|
||
|
||
def test_unnecessary_comment(): | ||
if os.path.exists(os.path.join(os.pardir, "app", "main.py")): | ||
main_path = os.path.join(os.pardir, "app", "main.py") | ||
else: | ||
main_path = os.path.join("app", "main.py") | ||
|
||
with open(main_path, "r") as main: | ||
main_content = main.read() | ||
|
||
assert ( | ||
"# write your code here" not in main_content | ||
), "Remove unnecessary comment" | ||
Comment on lines
+115
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test checks for an unnecessary comment in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the specified Python version is compatible with your project's dependencies. If your project supports multiple Python versions, consider testing against all of them.