Skip to content

Commit

Permalink
fix: Eliminate JsonRef proxies to avoid AttributeError: 'JsonRef' obj…
Browse files Browse the repository at this point in the history
…ect has no attribute 'get' exceptions
  • Loading branch information
jpmckinney committed Jul 11, 2023
1 parent bc6e39c commit 94f3176
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.12.4 (2023-07-11)

## Fixed

- Eliminate `JsonRef` proxies to avoid `AttributeError: 'JsonRef' object has no attribute 'get'` exceptions.

## 0.12.3 (2023-07-10)

### Changed
Expand Down
8 changes: 4 additions & 4 deletions libcoveocds/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def get_pkg_schema_obj(self, deref=False, use_extensions=True):
if hasattr(self, "_test_override_package_schema"):
with open(self._test_override_package_schema) as f:
if deref:
return jsonref.load(f, lazy_load=False)
return jsonref.load(f, merge_props=True, proxies=False)
return json.load(f)
else:
schema = self._get_schema(self._package_schema_name)
Expand All @@ -292,7 +292,7 @@ def get_pkg_schema_obj(self, deref=False, use_extensions=True):
if self._package_schema_name == "record-package-schema.json":
schema["definitions"]["record"]["properties"]["compiledRelease"] = patched
schema["definitions"]["record"]["properties"]["releases"]["oneOf"][1]["items"] = patched
schema = jsonref.replace_refs(schema, lazy_load=False)
schema = jsonref.replace_refs(schema, merge_props=True, proxies=False)
else:
schema["properties"]["releases"]["items"] = patched

Expand All @@ -306,8 +306,8 @@ def get_schema_obj(self, deref=False):
schema = self.builder.patched_release_schema(schema=self._get_schema("release-schema.json"))
if deref:
try:
# Don't use proxies=False. If "$ref" has "deprecated" as a sibling, it is lost.
schema = jsonref.replace_refs(schema, lazy_load=False)
# Preserve "deprecated" as a sibling of "$ref".
schema = jsonref.replace_refs(schema, merge_props=True, proxies=False)
except jsonref.JsonRefError as e:
# Callers must check json_deref_error.
self.json_deref_error = e.message
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extend-ignore = E203

[metadata]
name = libcoveocds
version = 0.12.3
version = 0.12.4
author = Open Contracting Partnership and Open Data Services Co-operative Limited
author_email = data@open-contracting.org
license = AGPLv3
Expand Down

0 comments on commit 94f3176

Please sign in to comment.