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

AttributeError: 'int' object has no attribute 'startswith' #169

Closed
swills opened this issue May 4, 2020 · 0 comments
Closed

AttributeError: 'int' object has no attribute 'startswith' #169

swills opened this issue May 4, 2020 · 0 comments

Comments

@swills
Copy link
Contributor

swills commented May 4, 2020

Environment

  • Python version: 3.7.7
  • PyKwalify version: 1.7.0 (02b7e21)

Steps to Reproduce

  1. pykwalify -s schema.yaml -d data.yaml

Schema

type: map
mapping:
  test:
    type: map
    mapping:
      0:
        type: str

Data

test:
  0: test

Expected Behavior

Validation Passed

Observed Behavior

Traceback (most recent call last):
  File "/usr/local/bin/pykwalify", line 11, in <module>
    load_entry_point('pykwalify==1.7.0', 'console_scripts', 'pykwalify')()
  File "/usr/local/lib/python3.7/site-packages/pykwalify/cli.py", line 98, in cli_entrypoint
    run(parse_cli())
  File "/usr/local/lib/python3.7/site-packages/pykwalify/cli.py", line 85, in run
    c.validate()
  File "/usr/local/lib/python3.7/site-packages/pykwalify/core.py", line 156, in validate
    self._start_validate(self.source)
  File "/usr/local/lib/python3.7/site-packages/pykwalify/core.py", line 198, in _start_validate
    root_rule = Rule(schema=self.schema)
  File "/usr/local/lib/python3.7/site-packages/pykwalify/rule.py", line 66, in __init__
    self.init(schema, "")
  File "/usr/local/lib/python3.7/site-packages/pykwalify/rule.py", line 443, in init
    func_mapping[k](v, rule, path)
  File "/usr/local/lib/python3.7/site-packages/pykwalify/rule.py", line 1180, in init_mapping_value
    rule.init(v, u"{0}/mapping/{1}".format(path, k))
  File "/usr/local/lib/python3.7/site-packages/pykwalify/rule.py", line 443, in init
    func_mapping[k](v, rule, path)
  File "/usr/local/lib/python3.7/site-packages/pykwalify/rule.py", line 1152, in init_mapping_value
    if k.startswith("regex;") or k.startswith("re;"):
AttributeError: 'int' object has no attribute 'startswith'

This is similar to #167 but slightly different. I think this is due to this bug:

yaml/pyyaml#98

Can be avoided by adding str() in the appropriate place, I can submit a pull request if you like.

swills added a commit to swills/pykwalify that referenced this issue May 5, 2020
swills added a commit to swills/pykwalify that referenced this issue May 5, 2020
swills added a commit to swills/pykwalify that referenced this issue May 5, 2020
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

No branches or pull requests

1 participant