Remove all "WPS" codes
This commit is contained in:
parent
8a5a652b3e
commit
9fcb3c8c14
52 changed files with 171 additions and 254 deletions
|
|
@ -21,9 +21,9 @@ log_config.fileConfig(context.config.config_file_name)
|
||||||
|
|
||||||
def include_object(obj, _name, type_, _reflected, _compare_to):
|
def include_object(obj, _name, type_, _reflected, _compare_to):
|
||||||
"""Only include the clean schema into --autogenerate migrations."""
|
"""Only include the clean schema into --autogenerate migrations."""
|
||||||
if ( # noqa:WPS337
|
if (
|
||||||
type_ in {'table', 'column'}
|
type_ in {'table', 'column'}
|
||||||
and hasattr(obj, 'schema') # noqa:WPS421 => fix for rare edge case
|
and hasattr(obj, 'schema') # => fix for rare edge case
|
||||||
and obj.schema != velofy_config.CLEAN_SCHEMA
|
and obj.schema != velofy_config.CLEAN_SCHEMA
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ def upgrade():
|
||||||
sa.Column('initial_zoom', sa.SmallInteger(), nullable=False),
|
sa.Column('initial_zoom', sa.SmallInteger(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_cities')),
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_cities')),
|
||||||
*(
|
*(
|
||||||
[ # noqa:WPS504
|
[
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['id'],
|
['id'],
|
||||||
[f'{config.ORIGINAL_SCHEMA}.cities.id'],
|
[f'{config.ORIGINAL_SCHEMA}.cities.id'],
|
||||||
|
|
@ -83,7 +83,7 @@ def upgrade():
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_couriers')),
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_couriers')),
|
||||||
*(
|
*(
|
||||||
[ # noqa:WPS504
|
[
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['id'],
|
['id'],
|
||||||
[f'{config.ORIGINAL_SCHEMA}.couriers.id'],
|
[f'{config.ORIGINAL_SCHEMA}.couriers.id'],
|
||||||
|
|
@ -148,7 +148,7 @@ def upgrade():
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_addresses')),
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_addresses')),
|
||||||
*(
|
*(
|
||||||
[ # noqa:WPS504
|
[
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['id'],
|
['id'],
|
||||||
[f'{config.ORIGINAL_SCHEMA}.addresses.id'],
|
[f'{config.ORIGINAL_SCHEMA}.addresses.id'],
|
||||||
|
|
@ -210,7 +210,7 @@ def upgrade():
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_restaurants')),
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_restaurants')),
|
||||||
*(
|
*(
|
||||||
[ # noqa:WPS504
|
[
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['id'],
|
['id'],
|
||||||
[f'{config.ORIGINAL_SCHEMA}.businesses.id'],
|
[f'{config.ORIGINAL_SCHEMA}.businesses.id'],
|
||||||
|
|
@ -628,7 +628,7 @@ def upgrade():
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_orders')),
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_orders')),
|
||||||
*(
|
*(
|
||||||
[ # noqa:WPS504
|
[
|
||||||
sa.ForeignKeyConstraint(
|
sa.ForeignKeyConstraint(
|
||||||
['id'],
|
['id'],
|
||||||
[f'{config.ORIGINAL_SCHEMA}.orders.id'],
|
[f'{config.ORIGINAL_SCHEMA}.orders.id'],
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ def upgrade():
|
||||||
TO
|
TO
|
||||||
train_horizon;
|
train_horizon;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|
@ -45,4 +45,4 @@ def downgrade():
|
||||||
TO
|
TO
|
||||||
training_horizon;
|
training_horizon;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ def upgrade():
|
||||||
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
||||||
DROP CONSTRAINT ck_orders_on_ordered_timestamps_21;
|
DROP CONSTRAINT ck_orders_on_ordered_timestamps_21;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
||||||
# Add forgotten check constraints to the `orders` table.
|
# Add forgotten check constraints to the `orders` table.
|
||||||
op.execute(
|
op.execute(
|
||||||
|
|
@ -38,7 +38,7 @@ def upgrade():
|
||||||
ADD CONSTRAINT check_orders_on_ordered_timestamps_placed_at_before_pickup_at
|
ADD CONSTRAINT check_orders_on_ordered_timestamps_placed_at_before_pickup_at
|
||||||
CHECK (placed_at < pickup_at);
|
CHECK (placed_at < pickup_at);
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
op.execute(
|
op.execute(
|
||||||
f"""
|
f"""
|
||||||
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
||||||
|
|
@ -55,7 +55,7 @@ def upgrade():
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
||||||
# This `UniqueConstraint` is needed by the `replayed_orders` table below.
|
# This `UniqueConstraint` is needed by the `replayed_orders` table below.
|
||||||
op.create_unique_constraint(
|
op.create_unique_constraint(
|
||||||
|
|
@ -403,17 +403,17 @@ def downgrade():
|
||||||
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
||||||
DROP CONSTRAINT check_orders_on_scheduled_orders_must_be_at_quarters_of_an_hour;
|
DROP CONSTRAINT check_orders_on_scheduled_orders_must_be_at_quarters_of_an_hour;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
op.execute(
|
op.execute(
|
||||||
f"""
|
f"""
|
||||||
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
||||||
DROP CONSTRAINT check_orders_on_ordered_timestamps_placed_at_before_pickup_at;
|
DROP CONSTRAINT check_orders_on_ordered_timestamps_placed_at_before_pickup_at;
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
op.execute(
|
op.execute(
|
||||||
f"""
|
f"""
|
||||||
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
ALTER TABLE {config.CLEAN_SCHEMA}.orders
|
||||||
ADD CONSTRAINT ck_orders_on_ordered_timestamps_21
|
ADD CONSTRAINT ck_orders_on_ordered_timestamps_21
|
||||||
CHECK (cancelled_at > delivery_at);
|
CHECK (cancelled_at > delivery_at);
|
||||||
""",
|
""",
|
||||||
) # noqa:WPS355
|
)
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ def build_docs(session: Session) -> None:
|
||||||
# Verify that all external links return 200 OK
|
# Verify that all external links return 200 OK
|
||||||
session.run('sphinx-build', '-b', 'linkcheck', DOCS_LOCATION, DOCS_BUILD)
|
session.run('sphinx-build', '-b', 'linkcheck', DOCS_LOCATION, DOCS_BUILD)
|
||||||
|
|
||||||
print(f'Docs are available at {os.getcwd()}/{DOCS_BUILD}index.html') # noqa:WPS421
|
print(f'Docs are available at {os.getcwd()}/{DOCS_BUILD}index.html')
|
||||||
|
|
||||||
|
|
||||||
@nox.session(name='venv', python=MAIN_PYTHON, venv_backend='none')
|
@nox.session(name='venv', python=MAIN_PYTHON, venv_backend='none')
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,6 @@ select = [
|
||||||
# wemake-python-styleguide
|
# wemake-python-styleguide
|
||||||
# Source: https://wemake-python-stylegui.de/en/latest/pages/usage/violations/index.html
|
# Source: https://wemake-python-stylegui.de/en/latest/pages/usage/violations/index.html
|
||||||
# ========================
|
# ========================
|
||||||
"WPS1", "WPS2", "WPS3", "WPS4", "WPS5", "WPS6",
|
|
||||||
# darglint => docstring matches implementation
|
# darglint => docstring matches implementation
|
||||||
"DAR0", "DAR1", "DAR2", "DAR3", "DAR4", "DAR5",
|
"DAR0", "DAR1", "DAR2", "DAR3", "DAR4", "DAR5",
|
||||||
# flake8-bandit => common security issues
|
# flake8-bandit => common security issues
|
||||||
|
|
@ -234,96 +233,36 @@ ignore = []
|
||||||
# If --ignore is passed on the command
|
# If --ignore is passed on the command
|
||||||
# line, still ignore the following:
|
# line, still ignore the following:
|
||||||
extend-ignore = [
|
extend-ignore = [
|
||||||
# TODO: New in `wemake-python-styleguide` v0.15 - v0.17, revisit in the tooling goal
|
|
||||||
"WPS110",
|
|
||||||
"WPS237",
|
|
||||||
"WPS238",
|
|
||||||
"WPS358",
|
|
||||||
"WPS456",
|
|
||||||
"WPS458",
|
|
||||||
"WPS459",
|
|
||||||
"WPS462",
|
|
||||||
"WPS469",
|
|
||||||
# Too long line => duplicate with E501.
|
# Too long line => duplicate with E501.
|
||||||
"B950",
|
"B950",
|
||||||
# Comply with black's style.
|
# Comply with black's style.
|
||||||
# Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8
|
# Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8
|
||||||
"E203", "W503", "WPS348",
|
"E203", "W503",
|
||||||
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
|
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
|
||||||
"PT023",
|
"PT023",
|
||||||
# Google's Python Style Guide is not reStructuredText
|
# Google's Python Style Guide is not reStructuredText
|
||||||
# until after being processed by Sphinx Napoleon.
|
# until after being processed by Sphinx Napoleon.
|
||||||
# Source: https://github.com/peterjc/flake8-rst-docstrings/issues/17
|
# Source: https://github.com/peterjc/flake8-rst-docstrings/issues/17
|
||||||
"RST201", "RST203", "RST210", "RST213", "RST301",
|
"RST201", "RST203", "RST210", "RST213", "RST301",
|
||||||
# The "too deep nesting" violation fires off "too early" and cannot be configured.
|
|
||||||
"WPS220",
|
|
||||||
# String constant over-use is checked visually by the programmer.
|
|
||||||
"WPS226",
|
|
||||||
# Function complexity is checked by `mccabe` (=C901),
|
|
||||||
# which yields the same result in most cases.
|
|
||||||
"WPS231",
|
|
||||||
# Modules as a whole are assumed to be not "too complex".
|
|
||||||
"WPS232",
|
|
||||||
# Allow underscores in numbers.
|
|
||||||
"WPS303",
|
|
||||||
# f-strings are ok.
|
|
||||||
"WPS305",
|
|
||||||
# Classes should not have to specify a base class.
|
|
||||||
"WPS306",
|
|
||||||
# Let's be modern: The Walrus is ok.
|
|
||||||
"WPS332",
|
|
||||||
# Let's not worry about the number of noqa's.
|
|
||||||
# Multi-line loops are ok.
|
|
||||||
"WPS352",
|
|
||||||
"WPS402",
|
|
||||||
# Putting logic into __init__.py files may be justified.
|
|
||||||
"WPS412",
|
|
||||||
# Allow multiple assignment, e.g., x = y = 123
|
|
||||||
"WPS429",
|
|
||||||
# There are no magic numbers.
|
|
||||||
"WPS432",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
per-file-ignores = [
|
per-file-ignores = [
|
||||||
# Top-levels of a sub-packages are intended to import a lot.
|
# Top-levels of a sub-packages are intended to import a lot.
|
||||||
"**/__init__.py:F401,WPS201",
|
"**/__init__.py:F401",
|
||||||
# Allow shadowing built-ins and reading __*__ variables.
|
|
||||||
"docs/conf.py:WPS125,WPS609",
|
|
||||||
# Type annotations are not strictly enforced.
|
# Type annotations are not strictly enforced.
|
||||||
"migrations/env.py:ANN0,ANN2",
|
"migrations/env.py:ANN0,ANN2",
|
||||||
# - ANN0, ANN2 => Type annotations are not strictly enforced.
|
# - ANN0, ANN2 => Type annotations are not strictly enforced.
|
||||||
# - S608 => Do not worry about SQL injection here.
|
# - S608 => Do not worry about SQL injection here.
|
||||||
# - WPS114, WPS118 => File names of revisions are ok.
|
"migrations/versions/*.py:ANN0,ANN2,S608",
|
||||||
# - WPS204, WPS213 => Revisions may have too many expressions.
|
# Type annotations are not strictly enforced.
|
||||||
"migrations/versions/*.py:ANN0,ANN2,S608,WPS114,WPS118,WPS204,WPS213",
|
"noxfile.py:ANN0,ANN2",
|
||||||
# - ANN0, ANN2 => Type annotations are not strictly enforced.
|
# No SQL injection as the inputs come from a safe source.
|
||||||
# - WPS202 => TODO (isort): Check if still too many module members.
|
"src/velofy/forecasts/timify.py:S608",
|
||||||
# - WPS213 => TODO (isort): Remove after simplifying the nox session "lint".
|
|
||||||
"noxfile.py:ANN0,ANN2,WPS202,WPS213",
|
|
||||||
# Allow upper case class variables within classes.
|
|
||||||
"src/velofy/configuration.py:WPS115",
|
|
||||||
# The module does not have too many imports.
|
|
||||||
"src/velofy/db/addresses_addresses.py:WPS201",
|
|
||||||
# The many noqa's are ok.
|
|
||||||
"src/velofy/forecasts/models/tactical/horizontal.py:WPS403",
|
|
||||||
# - S608 => No SQL injection as the inputs come from a safe source.
|
|
||||||
# - WPS403 => The many noqa's are ok.
|
|
||||||
"src/velofy/forecasts/timify.py:S608,WPS403",
|
|
||||||
# - ANN0, ANN2 => Type annotations are not strictly enforced.
|
# - ANN0, ANN2 => Type annotations are not strictly enforced.
|
||||||
# - D106 => The `Meta` class inside the factory_boy models do not need a docstring.
|
# - D106 => The `Meta` class inside the factory_boy models do not need a docstring.
|
||||||
# - S101 => `assert` statements are ok in the test suite.
|
# - S101 => `assert` statements are ok in the test suite.
|
||||||
# - S311 => The `random` module is not used for cryptography.
|
# - S311 => The `random` module is not used for cryptography.
|
||||||
# - WPS442 => Shadowing outer scopes occurs naturally with mocks.
|
"tests/*.py:ANN0,ANN2,D106,S101,S311",
|
||||||
# - WPS100 => `utils` should be a valid module name.
|
|
||||||
# - WPS118 => Test names may be longer than 40 characters.
|
|
||||||
# - WPS202, WPS204, WPS214 => Modules may have many test cases.
|
|
||||||
# - WPS221 => Do not check for Jones complexity in the test suite.
|
|
||||||
# - WPS338 => "Private" methods are really just a convention for
|
|
||||||
# fixtures without a return value.
|
|
||||||
# - WPS402 => We do not care about the number of "# noqa"s in the test suite.
|
|
||||||
# - WPS430 => Allow closures.
|
|
||||||
# - WPS437 => When testing, it is normal to use implementation details.
|
|
||||||
"tests/*.py:ANN0,ANN2,D106,S101,S311,WPS442,WPS100,WPS118,WPS202,WPS204,WPS214,WPS221,WPS338,WPS402,WPS430,WPS437",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Explicitly set mccabe's maximum complexity to 10 as recommended by
|
# Explicitly set mccabe's maximum complexity to 10 as recommended by
|
||||||
|
|
@ -331,12 +270,6 @@ per-file-ignores = [
|
||||||
# Source: https://en.wikipedia.org/wiki/Cyclomatic_complexity#Limiting_complexity_during_development
|
# Source: https://en.wikipedia.org/wiki/Cyclomatic_complexity#Limiting_complexity_during_development
|
||||||
max-complexity = 10
|
max-complexity = 10
|
||||||
|
|
||||||
# Allow more than wemake-python-styleguide's 5 local variables per function.
|
|
||||||
max-local-variables = 8
|
|
||||||
|
|
||||||
# Allow more than wemake-python-styleguide's 7 methods per class.
|
|
||||||
max-methods = 15
|
|
||||||
|
|
||||||
# Comply with black's style.
|
# Comply with black's style.
|
||||||
# Source: https://github.com/psf/black/blob/master/docs/the_black_code_style.md#line-length
|
# Source: https://github.com/psf/black/blob/master/docs/the_black_code_style.md#line-length
|
||||||
max-line-length = 88
|
max-line-length = 88
|
||||||
|
|
@ -344,18 +277,6 @@ max-line-length = 88
|
||||||
# Preview the code lines that cause errors.
|
# Preview the code lines that cause errors.
|
||||||
show-source = true
|
show-source = true
|
||||||
|
|
||||||
# ===================================
|
|
||||||
# wemake-python-styleguide's settings
|
|
||||||
# ===================================
|
|
||||||
allowed-domain-names = [
|
|
||||||
"data",
|
|
||||||
"obj",
|
|
||||||
"param",
|
|
||||||
"result",
|
|
||||||
"results",
|
|
||||||
"value",
|
|
||||||
]
|
|
||||||
max-name-length = 40
|
|
||||||
# darglint
|
# darglint
|
||||||
strictness = "long"
|
strictness = "long"
|
||||||
# flake8-docstrings
|
# flake8-docstrings
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ def db_revision(
|
||||||
|
|
||||||
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def ensure(*args: Any, **kwargs: Any) -> Any: # noqa:WPS430
|
def ensure(*args: Any, **kwargs: Any) -> Any:
|
||||||
"""Do not execute the `func` if the revision does not match."""
|
"""Do not execute the `func` if the revision does not match."""
|
||||||
if not os.getenv('TESTING'):
|
if not os.getenv('TESTING'):
|
||||||
result = subprocess.run( # noqa:S603,S607
|
result = subprocess.run( # noqa:S603,S607
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from velofy.forecasts import timify
|
||||||
@click.argument('time_step', default=60, type=int)
|
@click.argument('time_step', default=60, type=int)
|
||||||
@click.argument('train_horizon', default=8, type=int)
|
@click.argument('train_horizon', default=8, type=int)
|
||||||
@decorators.db_revision('8bfb928a31f8')
|
@decorators.db_revision('8bfb928a31f8')
|
||||||
def tactical_heuristic( # noqa:C901,WPS213,WPS216
|
def tactical_heuristic( # noqa:C901
|
||||||
city: str,
|
city: str,
|
||||||
side_length: int,
|
side_length: int,
|
||||||
time_step: int,
|
time_step: int,
|
||||||
|
|
@ -68,9 +68,7 @@ def tactical_heuristic( # noqa:C901,WPS213,WPS216
|
||||||
# Input validation.
|
# Input validation.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
city_obj = (
|
city_obj = db.session.query(db.City).filter_by(name=city.title()).one()
|
||||||
db.session.query(db.City).filter_by(name=city.title()).one() # noqa:WPS221
|
|
||||||
)
|
|
||||||
except orm_exc.NoResultFound:
|
except orm_exc.NoResultFound:
|
||||||
click.echo('NAME must be one of "Paris", "Lyon", or "Bordeaux"')
|
click.echo('NAME must be one of "Paris", "Lyon", or "Bordeaux"')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
@ -97,17 +95,17 @@ def tactical_heuristic( # noqa:C901,WPS213,WPS216
|
||||||
)
|
)
|
||||||
|
|
||||||
# Load the historic order data.
|
# Load the historic order data.
|
||||||
order_history = timify.OrderHistory(grid=grid, time_step=time_step) # noqa:WPS441
|
order_history = timify.OrderHistory(grid=grid, time_step=time_step)
|
||||||
order_history.aggregate_orders()
|
order_history.aggregate_orders()
|
||||||
|
|
||||||
# Run the tactical heuristic.
|
# Run the tactical heuristic.
|
||||||
|
|
||||||
for pixel in grid.pixels: # noqa:WPS441
|
for pixel in grid.pixels:
|
||||||
# Important: this check may need to be adapted once further
|
# Important: this check may need to be adapted once further
|
||||||
# commands are added the make `Forecast`s without the heuristic!
|
# commands are added the make `Forecast`s without the heuristic!
|
||||||
# Continue with forecasting on the day the last prediction was made ...
|
# Continue with forecasting on the day the last prediction was made ...
|
||||||
last_predict_at = (
|
last_predict_at = (
|
||||||
db.session.query(func.max(db.Forecast.start_at)) # noqa:WPS221
|
db.session.query(func.max(db.Forecast.start_at))
|
||||||
.join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id)
|
.join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id)
|
||||||
.join(db.Grid, db.Pixel.grid_id == db.Grid.id)
|
.join(db.Grid, db.Pixel.grid_id == db.Grid.id)
|
||||||
.filter(db.Forecast.pixel == pixel)
|
.filter(db.Forecast.pixel == pixel)
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ def show_version(ctx: cli_core.Context, _param: Any, value: bool) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Mimic the colors of `poetry version`.
|
# Mimic the colors of `poetry version`.
|
||||||
pkg_name = click.style(velofy.__pkg_name__, fg='green') # noqa:WPS609
|
pkg_name = click.style(velofy.__pkg_name__, fg='green')
|
||||||
version = click.style(velofy.__version__, fg='blue') # noqa:WPS609
|
version = click.style(velofy.__version__, fg='blue')
|
||||||
# Include a warning for development versions.
|
# Include a warning for development versions.
|
||||||
warning = click.style(' (development)', fg='red') if '.dev' in version else ''
|
warning = click.style(' (development)', fg='red') if '.dev' in version else ''
|
||||||
click.echo(f'{pkg_name}, version {version}{warning}')
|
click.echo(f'{pkg_name}, version {version}{warning}')
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class Address(meta.Base):
|
||||||
__tablename__ = 'addresses'
|
__tablename__ = 'addresses'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||||
primary_id = sa.Column(sa.Integer, nullable=False, index=True)
|
primary_id = sa.Column(sa.Integer, nullable=False, index=True)
|
||||||
created_at = sa.Column(sa.DateTime, nullable=False)
|
created_at = sa.Column(sa.DateTime, nullable=False)
|
||||||
place_id = sa.Column(sa.Unicode(length=120), nullable=False, index=True)
|
place_id = sa.Column(sa.Unicode(length=120), nullable=False, index=True)
|
||||||
|
|
@ -116,7 +116,7 @@ class Address(meta.Base):
|
||||||
return location
|
return location
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def x(self) -> int: # noqa=WPS111
|
def x(self) -> int:
|
||||||
"""The relative x-coordinate within the `.city` in meters.
|
"""The relative x-coordinate within the `.city` in meters.
|
||||||
|
|
||||||
On the implied x-y plane, the `.city`'s southwest corner is the origin.
|
On the implied x-y plane, the `.city`'s southwest corner is the origin.
|
||||||
|
|
@ -126,7 +126,7 @@ class Address(meta.Base):
|
||||||
return self.location.x
|
return self.location.x
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def y(self) -> int: # noqa=WPS111
|
def y(self) -> int:
|
||||||
"""The relative y-coordinate within the `.city` in meters.
|
"""The relative y-coordinate within the `.city` in meters.
|
||||||
|
|
||||||
On the implied x-y plane, the `.city`'s southwest corner is the origin.
|
On the implied x-y plane, the `.city`'s southwest corner is the origin.
|
||||||
|
|
@ -145,7 +145,7 @@ class Address(meta.Base):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property # pragma: no cover
|
@property # pragma: no cover
|
||||||
def map(self) -> folium.Map: # noqa:WPS125
|
def map(self) -> folium.Map:
|
||||||
"""Shortcut to the `.city.map` object."""
|
"""Shortcut to the `.city.map` object."""
|
||||||
return self.city.map
|
return self.city.map
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,9 +128,7 @@ class Path(meta.Base):
|
||||||
# We consider all 2-tuples of `Address`es. The symmetric graph is ...
|
# We consider all 2-tuples of `Address`es. The symmetric graph is ...
|
||||||
for first, second in itertools.combinations(addresses, 2):
|
for first, second in itertools.combinations(addresses, 2):
|
||||||
# ... implicitly enforced by a precedence constraint for the `.id`s.
|
# ... implicitly enforced by a precedence constraint for the `.id`s.
|
||||||
first, second = ( # noqa:WPS211
|
first, second = (first, second) if first.id < second.id else (second, first)
|
||||||
(first, second) if first.id < second.id else (second, first)
|
|
||||||
)
|
|
||||||
|
|
||||||
# If there is no `Path` object in the database ...
|
# If there is no `Path` object in the database ...
|
||||||
path = (
|
path = (
|
||||||
|
|
@ -158,7 +156,7 @@ class Path(meta.Base):
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
|
|
||||||
if google_maps:
|
if google_maps:
|
||||||
for path in paths: # noqa:WPS440
|
for path in paths:
|
||||||
path.sync_with_google_maps()
|
path.sync_with_google_maps()
|
||||||
|
|
||||||
return paths
|
return paths
|
||||||
|
|
@ -212,8 +210,8 @@ class Path(meta.Base):
|
||||||
# Source: https://developers.google.com/maps/documentation/directions/get-directions#Legs # noqa:E501
|
# Source: https://developers.google.com/maps/documentation/directions/get-directions#Legs # noqa:E501
|
||||||
route = response[0]['legs'][0]
|
route = response[0]['legs'][0]
|
||||||
|
|
||||||
self.bicycle_distance = route['distance']['value'] # noqa:WPS601
|
self.bicycle_distance = route['distance']['value']
|
||||||
self.bicycle_duration = route['duration']['value'] # noqa:WPS601
|
self.bicycle_duration = route['duration']['value']
|
||||||
|
|
||||||
# Each route consists of many "steps" that are instructions as to how to
|
# Each route consists of many "steps" that are instructions as to how to
|
||||||
# get from A to B. As a step's "start_location" may equal the previous step's
|
# get from A to B. As a step's "start_location" may equal the previous step's
|
||||||
|
|
@ -221,23 +219,23 @@ class Path(meta.Base):
|
||||||
# pairs that make up the path from `.first_address` to `.second_address`.
|
# pairs that make up the path from `.first_address` to `.second_address`.
|
||||||
steps: ordered_set.OrderedSet[Tuple[float, float]] = ordered_set.OrderedSet()
|
steps: ordered_set.OrderedSet[Tuple[float, float]] = ordered_set.OrderedSet()
|
||||||
for step in route['steps']:
|
for step in route['steps']:
|
||||||
steps.add( # noqa:WPS221
|
steps.add(
|
||||||
(step['start_location']['lat'], step['start_location']['lng']),
|
(step['start_location']['lat'], step['start_location']['lng']),
|
||||||
)
|
)
|
||||||
steps.add( # noqa:WPS221
|
steps.add(
|
||||||
(step['end_location']['lat'], step['end_location']['lng']),
|
(step['end_location']['lat'], step['end_location']['lng']),
|
||||||
)
|
)
|
||||||
|
|
||||||
steps.discard(self.first_address.location.lat_lng)
|
steps.discard(self.first_address.location.lat_lng)
|
||||||
steps.discard(self.second_address.location.lat_lng)
|
steps.discard(self.second_address.location.lat_lng)
|
||||||
|
|
||||||
self._directions = json.dumps(list(steps)) # noqa:WPS601
|
self._directions = json.dumps(list(steps))
|
||||||
|
|
||||||
db.session.add(self)
|
db.session.add(self)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@property # pragma: no cover
|
@property # pragma: no cover
|
||||||
def map(self) -> folium.Map: # noqa:WPS125
|
def map(self) -> folium.Map:
|
||||||
"""Convenience property to obtain the underlying `City.map`."""
|
"""Convenience property to obtain the underlying `City.map`."""
|
||||||
return self.first_address.city.map
|
return self.first_address.city.map
|
||||||
|
|
||||||
|
|
@ -256,7 +254,7 @@ class Path(meta.Base):
|
||||||
|
|
||||||
return points
|
return points
|
||||||
|
|
||||||
def draw( # noqa:WPS211
|
def draw(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
reverse: bool = False,
|
reverse: bool = False,
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class City(meta.Base):
|
||||||
__tablename__ = 'cities'
|
__tablename__ = 'cities'
|
||||||
|
|
||||||
# Generic columns
|
# Generic columns
|
||||||
id = sa.Column( # noqa:WPS125
|
id = sa.Column(
|
||||||
sa.SmallInteger,
|
sa.SmallInteger,
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
autoincrement=False,
|
autoincrement=False,
|
||||||
|
|
@ -110,12 +110,12 @@ class City(meta.Base):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property # pragma: no cover
|
@property # pragma: no cover
|
||||||
def map(self) -> folium.Map: # noqa:WPS125
|
def map(self) -> folium.Map:
|
||||||
"""A `folium.Map` object aligned with the city's viewport.
|
"""A `folium.Map` object aligned with the city's viewport.
|
||||||
|
|
||||||
See docstring for `.clear_map()` for further info.
|
See docstring for `.clear_map()` for further info.
|
||||||
"""
|
"""
|
||||||
if not hasattr(self, '_map'): # noqa:WPS421 note:d334120e
|
if not hasattr(self, '_map'): # note:d334120e
|
||||||
self.clear_map()
|
self.clear_map()
|
||||||
|
|
||||||
return self._map
|
return self._map
|
||||||
|
|
@ -137,7 +137,7 @@ class City(meta.Base):
|
||||||
db.session.query(db.Address)
|
db.session.query(db.Address)
|
||||||
.filter(
|
.filter(
|
||||||
db.Address.id.in_(
|
db.Address.id.in_(
|
||||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
db.session.query(db.Address.primary_id)
|
||||||
.join(db.Restaurant, db.Address.id == db.Restaurant.address_id)
|
.join(db.Restaurant, db.Address.id == db.Restaurant.address_id)
|
||||||
.filter(db.Address.city == self)
|
.filter(db.Address.city == self)
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|
@ -157,9 +157,9 @@ class City(meta.Base):
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
if len(restaurants) == 1:
|
if len(restaurants) == 1:
|
||||||
tooltip = f'{restaurants[0].name} (#{restaurants[0].id})' # noqa:WPS221
|
tooltip = f'{restaurants[0].name} (#{restaurants[0].id})'
|
||||||
else:
|
else:
|
||||||
tooltip = 'Restaurants ' + ', '.join( # noqa:WPS336
|
tooltip = 'Restaurants ' + ', '.join(
|
||||||
f'#{restaurant.id}' for restaurant in restaurants
|
f'#{restaurant.id}' for restaurant in restaurants
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -183,7 +183,7 @@ class City(meta.Base):
|
||||||
else:
|
else:
|
||||||
radius = 1
|
radius = 1
|
||||||
|
|
||||||
tooltip += f' | n_orders={n_orders}' # noqa:WPS336
|
tooltip += f' | n_orders={n_orders}'
|
||||||
|
|
||||||
address.draw(
|
address.draw(
|
||||||
radius=radius,
|
radius=radius,
|
||||||
|
|
@ -239,7 +239,7 @@ class City(meta.Base):
|
||||||
if not address.is_primary:
|
if not address.is_primary:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
marker = folium.Circle( # noqa:WPS317
|
marker = folium.Circle(
|
||||||
(address.latitude, address.longitude),
|
(address.latitude, address.longitude),
|
||||||
color=colors[address.zip_code],
|
color=colors[address.zip_code],
|
||||||
radius=1,
|
radius=1,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Courier(meta.Base):
|
||||||
__tablename__ = 'couriers'
|
__tablename__ = 'couriers'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||||
created_at = sa.Column(sa.DateTime, nullable=False)
|
created_at = sa.Column(sa.DateTime, nullable=False)
|
||||||
vehicle = sa.Column(sa.Unicode(length=10), nullable=False)
|
vehicle = sa.Column(sa.Unicode(length=10), nullable=False)
|
||||||
historic_speed = sa.Column('speed', postgresql.DOUBLE_PRECISION, nullable=False)
|
historic_speed = sa.Column('speed', postgresql.DOUBLE_PRECISION, nullable=False)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Customer(meta.Base):
|
||||||
__tablename__ = 'customers'
|
__tablename__ = 'customers'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
|
|
@ -35,15 +35,15 @@ class Customer(meta.Base):
|
||||||
Returns:
|
Returns:
|
||||||
self: enabling method chaining
|
self: enabling method chaining
|
||||||
""" # noqa:D402,DAR203
|
""" # noqa:D402,DAR203
|
||||||
self.orders[0].pickup_address.city.clear_map() # noqa:WPS219
|
self.orders[0].pickup_address.city.clear_map()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property # pragma: no cover
|
@property # pragma: no cover
|
||||||
def map(self) -> folium.Map: # noqa:WPS125
|
def map(self) -> folium.Map:
|
||||||
"""Shortcut to the `...city.map` object."""
|
"""Shortcut to the `...city.map` object."""
|
||||||
return self.orders[0].pickup_address.city.map # noqa:WPS219
|
return self.orders[0].pickup_address.city.map
|
||||||
|
|
||||||
def draw( # noqa:C901,WPS210
|
def draw( # noqa:C901
|
||||||
self,
|
self,
|
||||||
restaurants: bool = True,
|
restaurants: bool = True,
|
||||||
order_counts: bool = False, # pragma: no cover
|
order_counts: bool = False, # pragma: no cover
|
||||||
|
|
@ -72,7 +72,7 @@ class Customer(meta.Base):
|
||||||
db.Address.id.in_(
|
db.Address.id.in_(
|
||||||
row.primary_id
|
row.primary_id
|
||||||
for row in (
|
for row in (
|
||||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
db.session.query(db.Address.primary_id)
|
||||||
.join(db.Order, db.Address.id == db.Order.delivery_address_id)
|
.join(db.Order, db.Address.id == db.Order.delivery_address_id)
|
||||||
.filter(db.Order.customer_id == self.id)
|
.filter(db.Order.customer_id == self.id)
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|
@ -122,7 +122,7 @@ class Customer(meta.Base):
|
||||||
db.session.query(db.Address)
|
db.session.query(db.Address)
|
||||||
.filter(
|
.filter(
|
||||||
db.Address.id.in_(
|
db.Address.id.in_(
|
||||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
db.session.query(db.Address.primary_id)
|
||||||
.join(db.Order, db.Address.id == db.Order.pickup_address_id)
|
.join(db.Order, db.Address.id == db.Order.pickup_address_id)
|
||||||
.filter(db.Order.customer_id == self.id)
|
.filter(db.Order.customer_id == self.id)
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|
@ -132,14 +132,14 @@ class Customer(meta.Base):
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
for address in pickup_addresses: # noqa:WPS440
|
for address in pickup_addresses:
|
||||||
# Show the restaurant's name if there is only one.
|
# Show the restaurant's name if there is only one.
|
||||||
# Otherwise, list all the restaurants' ID's.
|
# Otherwise, list all the restaurants' ID's.
|
||||||
# We cannot show the `Order.restaurant.name` due to the aggregation.
|
# We cannot show the `Order.restaurant.name` due to the aggregation.
|
||||||
restaurants = (
|
restaurants = (
|
||||||
db.session.query(db.Restaurant)
|
db.session.query(db.Restaurant)
|
||||||
.join(db.Address, db.Restaurant.address_id == db.Address.id)
|
.join(db.Address, db.Restaurant.address_id == db.Address.id)
|
||||||
.filter(db.Address.primary_id == address.id) # noqa:WPS441
|
.filter(db.Address.primary_id == address.id)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
if len(restaurants) == 1: # type:ignore
|
if len(restaurants) == 1: # type:ignore
|
||||||
|
|
@ -147,7 +147,7 @@ class Customer(meta.Base):
|
||||||
f'{restaurants[0].name} (#{restaurants[0].id})' # type:ignore
|
f'{restaurants[0].name} (#{restaurants[0].id})' # type:ignore
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
tooltip = 'Restaurants ' + ', '.join( # noqa:WPS336
|
tooltip = 'Restaurants ' + ', '.join(
|
||||||
f'#{restaurant.id}' for restaurant in restaurants # type:ignore
|
f'#{restaurant.id}' for restaurant in restaurants # type:ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -156,7 +156,7 @@ class Customer(meta.Base):
|
||||||
db.session.query(db.Order)
|
db.session.query(db.Order)
|
||||||
.join(db.Address, db.Order.pickup_address_id == db.Address.id)
|
.join(db.Address, db.Order.pickup_address_id == db.Address.id)
|
||||||
.filter(db.Order.customer_id == self.id)
|
.filter(db.Order.customer_id == self.id)
|
||||||
.filter(db.Address.primary_id == address.id) # noqa:WPS441
|
.filter(db.Address.primary_id == address.id)
|
||||||
.count()
|
.count()
|
||||||
)
|
)
|
||||||
if n_orders >= 25:
|
if n_orders >= 25:
|
||||||
|
|
@ -170,9 +170,9 @@ class Customer(meta.Base):
|
||||||
else:
|
else:
|
||||||
radius = 1
|
radius = 1
|
||||||
|
|
||||||
tooltip += f' | n_orders={n_orders}' # noqa:WPS336
|
tooltip += f' | n_orders={n_orders}'
|
||||||
|
|
||||||
address.draw( # noqa:WPS441
|
address.draw(
|
||||||
radius=radius,
|
radius=radius,
|
||||||
color=config.RESTAURANT_COLOR,
|
color=config.RESTAURANT_COLOR,
|
||||||
fill_color=config.RESTAURANT_COLOR,
|
fill_color=config.RESTAURANT_COLOR,
|
||||||
|
|
@ -181,7 +181,7 @@ class Customer(meta.Base):
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
address.draw( # noqa:WPS441
|
address.draw(
|
||||||
radius=1,
|
radius=1,
|
||||||
color=config.RESTAURANT_COLOR,
|
color=config.RESTAURANT_COLOR,
|
||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class Forecast(meta.Base):
|
||||||
__tablename__ = 'forecasts'
|
__tablename__ = 'forecasts'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||||
pixel_id = sa.Column(sa.Integer, nullable=False, index=True)
|
pixel_id = sa.Column(sa.Integer, nullable=False, index=True)
|
||||||
start_at = sa.Column(sa.DateTime, nullable=False)
|
start_at = sa.Column(sa.DateTime, nullable=False)
|
||||||
time_step = sa.Column(sa.SmallInteger, nullable=False)
|
time_step = sa.Column(sa.SmallInteger, nullable=False)
|
||||||
|
|
@ -151,7 +151,7 @@ class Forecast(meta.Base):
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dataframe( # noqa:WPS210,WPS211
|
def from_dataframe(
|
||||||
cls,
|
cls,
|
||||||
pixel: db.Pixel,
|
pixel: db.Pixel,
|
||||||
time_step: int,
|
time_step: int,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class Grid(meta.Base):
|
||||||
__tablename__ = 'grids'
|
__tablename__ = 'grids'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column( # noqa:WPS125
|
id = sa.Column(
|
||||||
sa.SmallInteger,
|
sa.SmallInteger,
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
autoincrement=True,
|
autoincrement=True,
|
||||||
|
|
@ -63,7 +63,7 @@ class Grid(meta.Base):
|
||||||
return round((self.side_length**2) / 1_000_000, 1)
|
return round((self.side_length**2) / 1_000_000, 1)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def gridify(cls, city: db.City, side_length: int) -> db.Grid: # noqa:WPS210
|
def gridify(cls, city: db.City, side_length: int) -> db.Grid:
|
||||||
"""Create a fully populated `Grid` for a `city`.
|
"""Create a fully populated `Grid` for a `city`.
|
||||||
|
|
||||||
The `Grid` contains only `Pixel`s that have at least one
|
The `Grid` contains only `Pixel`s that have at least one
|
||||||
|
|
@ -124,7 +124,7 @@ class Grid(meta.Base):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property # pragma: no cover
|
@property # pragma: no cover
|
||||||
def map(self) -> folium.Map: # noqa:WPS125
|
def map(self) -> folium.Map:
|
||||||
"""Shortcut to the `.city.map` object."""
|
"""Shortcut to the `.city.map` object."""
|
||||||
return self.city.map
|
return self.city.map
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ Base: Any = orm.declarative_base(
|
||||||
metadata=sa.MetaData(
|
metadata=sa.MetaData(
|
||||||
schema=velofy.config.CLEAN_SCHEMA,
|
schema=velofy.config.CLEAN_SCHEMA,
|
||||||
naming_convention={
|
naming_convention={
|
||||||
'pk': 'pk_%(table_name)s', # noqa:WPS323
|
'pk': 'pk_%(table_name)s',
|
||||||
'fk': 'fk_%(table_name)s_to_%(referred_table_name)s_via_%(column_0_N_name)s', # noqa:E501,WPS323
|
'fk': 'fk_%(table_name)s_to_%(referred_table_name)s_via_%(column_0_N_name)s', # noqa:E501
|
||||||
'uq': 'uq_%(table_name)s_on_%(column_0_N_name)s', # noqa:WPS323
|
'uq': 'uq_%(table_name)s_on_%(column_0_N_name)s',
|
||||||
'ix': 'ix_%(table_name)s_on_%(column_0_N_name)s', # noqa:WPS323
|
'ix': 'ix_%(table_name)s_on_%(column_0_N_name)s',
|
||||||
'ck': 'ck_%(table_name)s_on_%(constraint_name)s', # noqa:WPS323
|
'ck': 'ck_%(table_name)s_on_%(constraint_name)s',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ from velofy import db
|
||||||
from velofy.db import meta
|
from velofy.db import meta
|
||||||
|
|
||||||
|
|
||||||
class Order(meta.Base): # noqa:WPS214
|
class Order(meta.Base):
|
||||||
"""An order by a `Customer` of the UDP."""
|
"""An order by a `Customer` of the UDP."""
|
||||||
|
|
||||||
__tablename__ = 'orders'
|
__tablename__ = 'orders'
|
||||||
|
|
||||||
# Generic columns
|
# Generic columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||||
_delivery_id = sa.Column('delivery_id', sa.Integer, index=True, unique=True)
|
_delivery_id = sa.Column('delivery_id', sa.Integer, index=True, unique=True)
|
||||||
customer_id = sa.Column(sa.Integer, nullable=False, index=True)
|
customer_id = sa.Column(sa.Integer, nullable=False, index=True)
|
||||||
placed_at = sa.Column(sa.DateTime, nullable=False, index=True)
|
placed_at = sa.Column(sa.DateTime, nullable=False, index=True)
|
||||||
|
|
@ -364,7 +364,7 @@ class Order(meta.Base): # noqa:WPS214
|
||||||
def corrected(self) -> bool:
|
def corrected(self) -> bool:
|
||||||
"""If any timestamp was corrected as compared to the original data."""
|
"""If any timestamp was corrected as compared to the original data."""
|
||||||
return (
|
return (
|
||||||
self.scheduled_delivery_at_corrected # noqa:WPS222 => too much logic
|
self.scheduled_delivery_at_corrected # => too much logic
|
||||||
or self.cancelled_at_corrected
|
or self.cancelled_at_corrected
|
||||||
or self.restaurant_notified_at_corrected
|
or self.restaurant_notified_at_corrected
|
||||||
or self.restaurant_confirmed_at_corrected
|
or self.restaurant_confirmed_at_corrected
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class Pixel(meta.Base):
|
||||||
__tablename__ = 'pixels'
|
__tablename__ = 'pixels'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||||
grid_id = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
grid_id = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||||
n_x = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
n_x = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||||
n_y = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
n_y = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||||
|
|
@ -141,11 +141,11 @@ class Pixel(meta.Base):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property # pragma: no cover
|
@property # pragma: no cover
|
||||||
def map(self) -> folium.Map: # noqa:WPS125
|
def map(self) -> folium.Map:
|
||||||
"""Shortcut to the `.city.map` object."""
|
"""Shortcut to the `.city.map` object."""
|
||||||
return self.grid.city.map
|
return self.grid.city.map
|
||||||
|
|
||||||
def draw( # noqa:C901,WPS210
|
def draw( # noqa:C901
|
||||||
self,
|
self,
|
||||||
restaurants: bool = True,
|
restaurants: bool = True,
|
||||||
order_counts: bool = False, # pragma: no cover
|
order_counts: bool = False, # pragma: no cover
|
||||||
|
|
@ -223,7 +223,7 @@ class Pixel(meta.Base):
|
||||||
f'{restaurants[0].name} (#{restaurants[0].id})' # type:ignore
|
f'{restaurants[0].name} (#{restaurants[0].id})' # type:ignore
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
tooltip = 'Restaurants ' + ', '.join( # noqa:WPS336
|
tooltip = 'Restaurants ' + ', '.join(
|
||||||
f'#{restaurant.id}' for restaurant in restaurants # type:ignore
|
f'#{restaurant.id}' for restaurant in restaurants # type:ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ class Pixel(meta.Base):
|
||||||
else:
|
else:
|
||||||
radius = 1
|
radius = 1
|
||||||
|
|
||||||
tooltip += f' | n_orders={n_orders}' # noqa:WPS336
|
tooltip += f' | n_orders={n_orders}'
|
||||||
|
|
||||||
address.draw(
|
address.draw(
|
||||||
radius=radius,
|
radius=radius,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class ReplaySimulation(meta.Base):
|
||||||
__tablename__ = 'replay_simulations'
|
__tablename__ = 'replay_simulations'
|
||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) # noqa:WPS125
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||||
city_id = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
city_id = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||||
strategy = sa.Column(sa.Unicode(length=100), nullable=False, index=True)
|
strategy = sa.Column(sa.Unicode(length=100), nullable=False, index=True)
|
||||||
# `.run` may be used as random seed.
|
# `.run` may be used as random seed.
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue