Skip to content

Commit

Permalink
style: Reformat the source code and unit tests in accordance with the…
Browse files Browse the repository at this point in the history
… rules of black v23.1.0 (new release).
  • Loading branch information
laurent-laporte-pro committed Feb 2, 2023
1 parent 5e5165a commit 962a33e
Show file tree
Hide file tree
Showing 36 changed files with 2 additions and 41 deletions.
1 change: 0 additions & 1 deletion antarest/core/maintenance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def build_maintenance_manager(
cache: ICache,
event_bus: IEventBus = DummyEventBusService(),
) -> MaintenanceService:

repository = MaintenanceRepository()
service = MaintenanceService(config, repository, event_bus, cache)

Expand Down
2 changes: 0 additions & 2 deletions antarest/core/maintenance/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def _get_maintenance_data(
db_call: Callable[[], Optional[str]],
default_value: str,
) -> str:

try:
data_json = self.cache.get(cache_id)
if data_json is not None and "content" in data_json.keys():
Expand Down Expand Up @@ -101,7 +100,6 @@ def _set_maintenance_data(
db_call: Callable[[str], None],
request_params: RequestParameters,
) -> None:

if not request_params.user or not request_params.user.is_site_admin():
raise UserHasNotPermissionError()

Expand Down
1 change: 0 additions & 1 deletion antarest/core/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def upgrade_db(config_file: Path) -> None:

os.environ.setdefault("ANTAREST_CONF", str(config_file))
alembic_cfg = Config(str(get_local_path() / "alembic.ini"))
alembic_cfg.stdout = StringIO()
Expand Down
1 change: 0 additions & 1 deletion antarest/core/tasks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def build_taskjob_manager(
config: Config,
event_bus: IEventBus = DummyEventBusService(),
) -> ITaskService:

repository = TaskJobRepository()
service = TaskJobService(config, repository, event_bus)

Expand Down
1 change: 0 additions & 1 deletion antarest/core/tasks/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ def _run_task(
task_id: str,
custom_event_messages: Optional[CustomTaskEventMessages] = None,
) -> None:

self.event_bus.push(
Event(
type=EventType.TASK_RUNNING,
Expand Down
1 change: 0 additions & 1 deletion antarest/core/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def get_local_path() -> Path:


def get_commit_id(path_resources: Path) -> Optional[str]:

commit_id = None

path_commit_id = path_resources / "commit_id"
Expand Down
1 change: 0 additions & 1 deletion antarest/eventbus/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def build_eventbus(
autostart: bool = True,
redis_client: Optional[Redis] = None, # type: ignore
) -> IEventBus:

eventbus = EventBusService(
RedisEventBus(redis_client)
if redis_client is not None
Expand Down
1 change: 0 additions & 1 deletion antarest/eventbus/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ async def broadcast(
def configure_websockets(
application: FastAPI, config: Config, event_bus: IEventBus
) -> None:

manager = ConnectionManager()

async def send_event_to_ws(event: Event) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ def run_study(
launcher_parameters: LauncherParametersDTO,
params: RequestParameters,
) -> None:

thread = threading.Thread(
target=self._run_study,
args=(study_uuid, job_id, launcher_parameters, version),
Expand Down
1 change: 0 additions & 1 deletion antarest/launcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def build_launcher(
event_bus: IEventBus = DummyEventBusService(),
service_launcher: Optional[LauncherService] = None,
) -> Optional[LauncherService]:

if not service_launcher:
repository = JobResultRepository()
# keep old job results
Expand Down
2 changes: 0 additions & 2 deletions antarest/launcher/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def get_jobs(
filter_orphans: bool = True,
latest: Optional[int] = None,
) -> List[JobResult]:

if study_uid is not None:
job_results = self.job_result_repository.find_by_study(study_uid)
else:
Expand Down Expand Up @@ -501,7 +500,6 @@ def _import_fallback_output(
shutil.copytree(output_path, imported_output_path)
imported_output_path.rename(Path(job_output_path, output_name))
else:

shutil.copy(
output_path, job_output_path / f"{output_name}.zip"
)
Expand Down
1 change: 0 additions & 1 deletion antarest/login/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __init__(
[], Dict[str, Any]
] = AuthJWT().get_raw_jwt, # Test only
):

self.disabled = config.security.disabled
self.verify = verify
self.get_identity = get_identity
Expand Down
1 change: 0 additions & 1 deletion antarest/login/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ def delete_bot(self, id: int, params: RequestParameters) -> None:
)
)
):

logger.info("bot %d deleted by user %s", id, params.get_user_id())
for role in self.roles.get_all_by_user(user=id):
self.roles.delete(user=role.identity_id, group=role.group_id)
Expand Down
2 changes: 1 addition & 1 deletion antarest/matrixstore/business/matrix_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def update_matrix_content_with_coordinates(
coordinates: List[Tuple[int, int]],
operation: Operation,
) -> pd.DataFrame:
for (row, column) in coordinates:
for row, column in coordinates:
df.iat[row, column] = operation.compute(
df.iat[row, column], use_coords=True
)
Expand Down
1 change: 0 additions & 1 deletion antarest/study/business/timeseries_config_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def __get_form_fields_for_type(
ts_type: TSType,
general_data: JSON,
) -> Optional[TSFormFieldsForType]:

general = general_data.get("general", {})
input_ = general_data.get("input", {})
output = general_data.get("output", {})
Expand Down
1 change: 0 additions & 1 deletion antarest/study/business/xpansion_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ def _assert_candidate_is_correct(
def add_candidate(
self, study: Study, xpansion_candidate_dto: XpansionCandidateDTO
) -> None:

file_study = self.study_storage_service.get_storage(study).get_raw(
study
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def load(
expanded: bool = False,
formatted: bool = True,
) -> bytes:

file_path, tmp_dir = self._get_real_file_path()

if file_path.exists():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def check_errors(
url: Optional[List[str]] = None,
raising: bool = False,
) -> List[str]:

errors = []
if any(
a not in data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def build(self) -> TREE:
}

if not self.simulation.error:

children["annualSystemCost"] = RawFileNode(
self.context, self.config.next_file("annualSystemCost.txt")
)
Expand Down
3 changes: 0 additions & 3 deletions antarest/study/storage/study_download_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def level_output_filter(
url: str,
data: StudyDownloadDTO,
) -> None:

cluster_details = [f"details-{data.level.value}"]
if study.config.enr_modelling == ENR_MODELLING.CLUSTERS.value:
cluster_details += [f"details-res-{data.level.value}"]
Expand Down Expand Up @@ -150,7 +149,6 @@ def apply_type_filters(
first_element_type_condition: bool,
second_element_type_condition: Callable[[str], bool],
) -> None:

if first_element_type_condition:
if data.type == StudyDownloadType.LINK and isinstance(
type_elm[elm], Area
Expand Down Expand Up @@ -415,7 +413,6 @@ def export(
if filetype == ExportFormat.ZIP
else tarfile.open(target_file, mode="w:gz")
) as output_data:

# 2 - Create CSV files
for ts_data in matrix.data:
output = StringIO()
Expand Down
1 change: 0 additions & 1 deletion antarest/study/storage/variantstudy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@


Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ def generate_update_district(
study: FileStudy,
district_id: str,
) -> ICommand:

study_config = study.config
study_tree = study.tree
district_config = study_config.sets[district_id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def _remove_area_from_time_series(self, study_data: FileStudy) -> None:
study_data.tree.delete(["input", "thermal", "series", self.id])

def _apply(self, study_data: FileStudy) -> CommandOutput:

study_data.tree.delete(["input", "areas", self.id])

study_data.tree.delete(["input", "hydro", "allocation", self.id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def get_inner_matrices(self) -> List[str]:
def _remove_cluster_from_binding_constraints(
self, study_data: FileStudy
) -> None:

binding_constraints = study_data.tree.get(
["input", "bindingconstraints", "bindingconstraints"]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,6 @@ def _generate_config(
config: FileStudyTreeConfig,
notifier: TaskUpdateNotifier = noop_notifier,
) -> Tuple[GenerationResultInfoDTO, FileStudyTreeConfig]:

commands, notify = self._get_commands_and_notifier(
variant_study=variant_study, notifier=notifier
)
Expand Down
1 change: 0 additions & 1 deletion antarest/study/web/watcher_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def scan_dir(
path: str,
current_user: JWTUser = Depends(auth.get_current_user),
) -> Any:

params = RequestParameters(user=current_user)
if path:
# The front actually sends <workspace>/<path/to/folder>
Expand Down
1 change: 0 additions & 1 deletion antarest/tools/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ def generate_study(
host: Optional[str] = None,
token: Optional[str] = None,
) -> GenerationResultInfoDTO:

if study_id is not None and host is not None:
generator: IVariantGenerator = RemoteVariantGenerator(
study_id, host, token
Expand Down
1 change: 0 additions & 1 deletion antarest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def create_matrix_gc(
study_service: Optional[StudyService] = None,
matrix_service: Optional[MatrixService] = None,
) -> MatrixGarbageCollector:

if study_service and matrix_service:
return MatrixGarbageCollector(
config=config,
Expand Down
1 change: 0 additions & 1 deletion tests/core/test_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test_service_without_cache() -> None:


def test_service_with_cache() -> None:

repo_mock = Mock(spec=MaintenanceRepository)
cache = Mock()
event_bus = Mock()
Expand Down
1 change: 0 additions & 1 deletion tests/core/test_utils_bp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

@pytest.mark.unit_test
def test_version() -> None:

mock_storage_service = Mock()
mock_storage_service.study_service.path_resources = Path("/")

Expand Down
1 change: 0 additions & 1 deletion tests/storage/business/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def build_storage_service(workspace: Path, uuid: str) -> RawStudyService:

@pytest.mark.unit_test
def test_import_study(tmp_path: Path) -> None:

name = "my-study"
study_path = tmp_path / name
study_path.mkdir()
Expand Down
2 changes: 0 additions & 2 deletions tests/storage/integration/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def assert_data(data: bytes):


def test_exporter_file(tmp_path: Path, sta_mini_zip_path: Path):

data = assert_url_content(
url="/v1/studies/STA-mini/export",
tmp_dir=tmp_path,
Expand All @@ -97,7 +96,6 @@ def test_exporter_file(tmp_path: Path, sta_mini_zip_path: Path):


def test_exporter_file_no_output(tmp_path: Path, sta_mini_zip_path: Path):

data = assert_url_content(
url="/v1/studies/STA-mini/export?no-output",
tmp_dir=tmp_path,
Expand Down
1 change: 0 additions & 1 deletion tests/storage/repository/filesystem/test_folder_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def test_filter():


def test_delete(tmp_path: Path):

folder_node = tmp_path / "folder_node"
folder_node.mkdir()
sub_folder = folder_node / "sub_folder"
Expand Down
1 change: 0 additions & 1 deletion tests/storage/repository/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def test_study_inheritance():

@with_db_context
def test_cache():

user = User(id=0, name="admin")
group = Group(id="my-group", name="group")

Expand Down
1 change: 0 additions & 1 deletion tests/storage/web/test_studies_bp.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ def test_study_permission_management(tmp_path: Path) -> None:

@pytest.mark.unit_test
def test_get_study_versions(tmp_path: Path) -> None:

app = FastAPI(title=__name__)
build_study_service(
app,
Expand Down
2 changes: 1 addition & 1 deletion tests/variantstudy/test_command_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class TestCommandFactory:
def setup_class(self):
for (module_loader, name, ispkg) in pkgutil.iter_modules(
for module_loader, name, ispkg in pkgutil.iter_modules(
["antarest/study/storage/variantstudy/model/command"]
):
importlib.import_module(
Expand Down

0 comments on commit 962a33e

Please sign in to comment.