From 018e874fcd6d08d87c0c44f550bc306bc7f8c1a7 Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Thu, 9 Mar 2023 00:25:04 -0800 Subject: [PATCH] lint --- .../src/opentelemetry/semconv/main.py | 19 +++++++++++++++---- .../semconv/model/semantic_convention.py | 4 +++- .../opentelemetry/semconv/templating/code.py | 1 - .../tests/semconv/model/test_correct_parse.py | 6 ++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/semantic-conventions/src/opentelemetry/semconv/main.py b/semantic-conventions/src/opentelemetry/semconv/main.py index f11cc733..dde3a5de 100644 --- a/semantic-conventions/src/opentelemetry/semconv/main.py +++ b/semantic-conventions/src/opentelemetry/semconv/main.py @@ -37,7 +37,11 @@ def parse_semconv(args, parser) -> SemanticConventionSet: semconv.parse(file) if args.reference_only is not None: - reference_files = [f for f in glob_file_list(args.yaml_root, args.reference_only) if is_yaml_file(f)] + reference_files = [ + f + for f in glob_file_list(args.yaml_root, args.reference_only) + if is_yaml_file(f) + ] for file in sorted(reference_files): semconv.parse(file, True) @@ -46,9 +50,11 @@ def parse_semconv(args, parser) -> SemanticConventionSet: sys.exit(1) return semconv + def is_yaml_file(file: str) -> bool: return file.endswith(".yaml") or file.endswith(".yml") + def glob_file_list(folder: str, pattern: str) -> List[str]: if not pattern: return [] @@ -105,9 +111,11 @@ def find_yaml(args): glob_file_list(args.yaml_root if args.yaml_root else "", args.exclude) ) reference_only = set( - glob_file_list(args.yaml_root if args.yaml_root else "", args.reference_only) + glob_file_list( + args.yaml_root if args.yaml_root else "", args.reference_only + ) ) - exclude.update(reference_only) + exclude.update(reference_only) yaml_files = set( glob.glob(f"{args.yaml_root}/**/*.yaml", recursive=True) @@ -237,7 +245,10 @@ def setup_parser(): "--exclude", "-e", help="Exclude the matching files using GLOB syntax", type=str ) parser.add_argument( - "--reference-only", "-r", help="Additional files to resolve references only (and extends) using GLOB syntax", type=str + "--reference-only", + "-r", + help="Additional files to resolve references only (and extends) using GLOB syntax", + type=str, ) parser.add_argument( "files", diff --git a/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py b/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py index aca15697..c8d04ced 100644 --- a/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py +++ b/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py @@ -300,7 +300,9 @@ class SemanticConventionSet: debug: bool models: typing.Dict[str, BaseSemanticConvention] = field(default_factory=dict) - extended_models: typing.Dict[str, BaseSemanticConvention] = field(default_factory=dict) + extended_models: typing.Dict[str, BaseSemanticConvention] = field( + default_factory=dict + ) errors: bool = False def parse(self, file, ref_only=False): diff --git a/semantic-conventions/src/opentelemetry/semconv/templating/code.py b/semantic-conventions/src/opentelemetry/semconv/templating/code.py index 7a322058..1efd0c56 100644 --- a/semantic-conventions/src/opentelemetry/semconv/templating/code.py +++ b/semantic-conventions/src/opentelemetry/semconv/templating/code.py @@ -244,7 +244,6 @@ def render( template.stream(data).dump(output_name) else: data = self.get_data_single_file(semconvset, template_path) - print (data) template = env.get_template(file_name, globals=data) template.globals["now"] = datetime.datetime.utcnow() template.globals["version"] = os.environ.get("ARTIFACT_VERSION", "dev") diff --git a/semantic-conventions/src/tests/semconv/model/test_correct_parse.py b/semantic-conventions/src/tests/semconv/model/test_correct_parse.py index a516712a..7217e91f 100644 --- a/semantic-conventions/src/tests/semconv/model/test_correct_parse.py +++ b/semantic-conventions/src/tests/semconv/model/test_correct_parse.py @@ -735,7 +735,7 @@ def test_reference_only_ref(self): semconv.finish() self.assertEqual(len(semconv.models), 3) - + def test_reference_only_extends(self): semconv = SemanticConventionSet(debug=False) semconv.parse(self.load_file("yaml/extends/child.http.yaml")) @@ -750,9 +750,7 @@ def test_reference_only_extends(self): "prefix": "child.http", "extends": "http.server", "n_constraints": 1, - "attributes": [ - "http.server_name", - ], + "attributes": ["http.server_name"], } self.semantic_convention_check(list(semconv.models.values())[0], expected)