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

Fix for Schema with recuvsive imports #133

Merged
merged 4 commits into from
May 15, 2024

Conversation

Sam-el0
Copy link
Contributor

@Sam-el0 Sam-el0 commented May 12, 2024

Hi @manusimidt,

This should be a low overhead fix for when schemas have recuvsive imports using a set to track imported URIs in the recursive parse_taxonomy functions.

Many thanks,
Sam

@manusimidt
Copy link
Owner

Encountered some issues with the changes.

from xbrl.cache import HttpCache
from xbrl.instance import XbrlParser, XbrlInstance

cache: HttpCache = HttpCache('./cache')
xbrlParser = XbrlParser(cache)

url = "https://www.sec.gov/Archives/edgar/data/2488/000000248822000170/amd-20220924.htm"
inst: XbrlInstance = xbrlParser.parse_instance(url, cache)

results for me in:

Traceback (most recent call last):
  File "C:\Users\manus\Code\python\py-xbrl\workdir\test_pull_109.py", line 8, in <module>
    inst: XbrlInstance = xbrlParser.parse_instance(url, cache)
  File "C:\Users\manus\Code\python\py-xbrl\xbrl\instance.py", line 740, in parse_instance
    return parse_ixbrl_url(uri, self.cache) if is_url(uri) else parse_ixbrl(uri, self.cache, instance_url, encoding)
  File "C:\Users\manus\Code\python\py-xbrl\xbrl\instance.py", line 426, in parse_ixbrl_url
    return parse_ixbrl(instance_path, cache, instance_url, encoding)
  File "C:\Users\manus\Code\python\py-xbrl\xbrl\instance.py", line 474, in parse_ixbrl
    taxonomy: TaxonomySchema = parse_taxonomy_url(schema_url, cache, imported_schema_uris)
TypeError: unhashable type: 'set'

Process finished with exit code 1

I will try to find a fix

@manusimidt manusimidt linked an issue May 14, 2024 that may be closed by this pull request
@Sam-el0
Copy link
Contributor Author

Sam-el0 commented May 14, 2024

Ah good catch, just pushed a fix. I left in some differences between the ixbrl and xbrl functions. Key being is you cannot pass the set to parse_taxonomy_url. Works with your example now.

@manusimidt
Copy link
Owner

Looks good now. All my tests are now executed properly. Thanks a lot for the PR!

@manusimidt manusimidt merged commit 2205e06 into manusimidt:main May 15, 2024
2 checks passed
@manusimidt
Copy link
Owner

I will release a new version of py-xbrl (containing #133) next week

@pnatusch
Copy link

pnatusch commented May 19, 2024 via email

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

Successfully merging this pull request may close these issues.

Infinite recursion loops with cyclic taxonomy imports.
3 participants