Skip to content
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

chore: minor cleanup in app, main and package init #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

afuetterer
Copy link
Contributor

@afuetterer afuetterer commented Jul 28, 2024

Description

This PR offers a couple of minor cleanups, see comments in the changed files.

Types of changes

  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes

Checklist

  • I have read the contributor guide.
  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@@ -2,15 +2,13 @@
#
# SPDX-License-Identifier: MIT

# coding: utf-8
# ruff: noqa: F401
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We change from ignoring all violations to the one we need here: "F401", unused import.

This enables us e.g. to sort the imports.

myjsonifier = Jsonifier(json, cls=encoder.CustomJSONEncoder)
# app = connexion.FlaskApp(__name__, specification_dir=YAML_DIR, jsonifier=encoder.CustomJsonifier)
app = connexion.App(__name__, specification_dir=YAML_DIR, jsonifier=myjsonifier)
jsonifier = Jsonifier(json, cls=encoder.CustomJSONEncoder)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed myjsonifier and removed unused code for readability.

@@ -7,54 +7,43 @@
import argparse
import configparser
import logging
import os
import logging.config
from pathlib import Path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We move from using os.path to the modern pathlib.Path.

# YAML_DIR = os.path.join(my_path, config['SERVICE']['yaml_directory'])
METRIC_YML_PATH = os.path.join(ROOT_DIR, YAML_DIR)
print("YAML PATH", METRIC_YML_PATH)
"""SPDX_URL = config['EXTERNAL']['spdx_license_github']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused lines for readability.

logger.info(f"Total subjects area of imported metadata standards : {len(preproc.metadata_standards)}")
logger.info(f"Total LD vocabs imported : {len(preproc.getLinkedVocabs())}")
logger.info(f"Total default namespaces specified : {len(preproc.getDefaultNamespaces())}")
logger.info("Total SPDX licenses: %s", preproc.get_total_licenses())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per flake8-logging-format we use %s instead of f-string in logging messages.

logging_config = configparser.ConfigParser()
logging_config.read(log_configfile)

logging.config.fileConfig(log_configfile, defaults={"logfilename": log_file_path})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now use the logging config file (again).

@afuetterer
Copy link
Contributor Author

Resolved merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant