question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

any() inside included element causes error

See original GitHub issue

Issue Description

The following schema results in an error while parsing the schema:

test_1: include('test_2')

---
test_2: any(str(), int())

Relevant part of stack trace:

File “/usr/local/lib/python2.7/site-packages/yamale/yamale.py”, line 17, in make_schema s.add_include(raw_schema) File “/usr/local/lib/python2.7/site-packages/yamale/schema/schema.py”, line 20, in add_include validators=self.validators) File “/usr/local/lib/python2.7/site-packages/yamale/schema/schema.py”, line 14, in init self._schema = self._process_schema(schema_dict, self.validators) File “/usr/local/lib/python2.7/site-packages/yamale/schema/schema.py”, line 36, in _process_schema raise SyntaxError(str(e) + ’ at node '%s' in file %s’ % (key, self.name)) SyntaxError: Invalid schema expression: ‘i’. name ‘i’ is not defined at node ‘11’ in file test_2

This is with Python 2.7 if that matters

So, if I want an element to contain one of two possible types of value, I need to do something like this instead and do some additional validation in the code that at least one of them is present:

test_1: include('test_2')

---
test_2:
  test_3: str(required=False)
  test_4: int(required=False)

Not sure if this is intended. Am I missing something or is there no neater way to do this? Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cblakkancommented, Sep 22, 2016

No problem, glad to help.

0reactions
Shplorfcommented, Sep 22, 2016

Okay yes I ran into a syntax error and misinterpreted it when I was trying an alternative way to write the schema. Once I fixed the syntax error it worked. Sorry to bother!

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - Why is it causing an error when i put a <p> inside of ...
Most notably, block-level elements, such as <div> , are not allowed inside inline elements such as <span> . This error is telling you...
Read more >
Error Explanations for The W3C Markup Validation Service
The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs". Entity references...
Read more >
Handling common HTML and CSS problems - MDN Web Docs
Basically, it is a matter of checking whether your HTML and CSS code is well formed and doesn't contain any syntax errors.
Read more >
Arrays in C++
An array is a collection of elements of the same type placed in contiguous memory locations that can be individually referenced by using...
Read more >
TRY...CATCH (Transact-SQL) - SQL Server
Including any other statements between the END TRY and BEGIN CATCH ... CATCH construct, any error in the nested TRY block will pass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found