Pykwalify

Latest version: v1.7.0

Safety actively analyzes 629723 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 4

1.6.0

New keywords:
- Add support for keyword _example_. It does nothing and have no validation done on it.
- Add support for keyword _version_. It does nothing and have no validation done on it.
- Add support for keyword _date_ and added support keyword _format_. This can be used to validate many different types of _datetime_ objects.
- Add support for keyword _length_. It is very similar to _range_ but works primarily string types.
- Add support for keyword _assert_. It works by running the python code _assert <assert-expr>_ and check if any exception is raised.
This feature is considered dangerouns becuase there is only simple logic to prevent escaping out from validation.

Bug fixes:
- Fixed a bug where regexes marked as 'required' in a map were matched as strings, rather than regexes.
- Fixed a bug where the type validation did not work when schema specefied a sequence of map objects. It now outputs a proper `...is not a dict...` error instead.
- Fixed a bug in _unique_ validation when a key that it tried to lookup in the data would not exists.
Now it just ignores that it did not find any value becuase a missing value do not impact validation.
- Fixed a bug with keyword _ident_ when the rule value was verified to be a _boolean_. It now only accepts _boolean_ values as expected.
- Fixed a bug where if _allowempty_ was specefied in a mapping type inside a sequence type then it would not properly validate.
- Fixed a bug where loaded extensions would not allways work in complex & nested objects.
- Fixed a major bug in very nested _seq_ schemas where if the schema expected another _seq_ but the value was something else it would not raise it as a validation error.
This has now been fixed and now raises the proper error.
- Fixed a bug where include directive would not work in all cases when used inside a key in a mapping block.

New features:
- It is now possible to specify a default rule when using a mapping.
The rule will be used whenever no other key could be found.
This is a port of a missing feature from original kwalify implementation.
- Added new helper method _keywords_ to _Rule_ class that can output all active keywords for any _Rule_ object.
This helps when debugging code to be able to easily dump what all active keywords for any _Rule_ object.
- Added new cli flag _--strict-rule-validation_ that will validate that all used keywords in all _Rule_ objects only uses the rules that is supported by each defined type.
If you only use a _Core_ object then set _strict_rule_validation=True_ when creating the _Core_ object instance.
This feature is opt-in in this releaes but will be mandatory in _releases >= 1.7.0_.
- Added new cli flag _--fix-ruby-style-regex_ that will trim slashes from ruby style regex/patterns.
When using this flag the first and last _/_ will be trimmed of the pattern before running validation.
If you only use a _Core_ object then set _fix_ruby_style_regex=True_ when creating the _Core_ object instance.
Default behaviour will still be that you should use python style regex values but this flag can help in some cases when you can't change the schema.
- Added new cli flag _--allow-assertions_ that will enable the otherwise blocked keyword _assert_.
This flag was introduced so that pykwalify would not assert assertions without user controll.
Default behaviour will be to raise a _CoreError_ is assertion is used but not allowed explicitly.
If you only use a _Core_ object then set _allow_assertions=True_ when creating the _Core_ object instance.

Changed behaviour:
- Removed the force of _UTF-8_ encoding when importing pykwalify package. It caused issues with _jypiter notebooks_ on python 2.7.x
Added documentation in Readme regarding the suggested solution to use _PYTHONIOENCODING=UTF-8_ if the default solution do not work.
- Validation do no longer continue to process things like _pattern_, _regex_, _timestamp_, _range_ and other additional checks
if the type check fails. This can cause problems where previous errors will now initially be silenced when the typecheck for
that value fails, but reappear again when the type check is fixed. (sbrunner)
- Catches _TypeError_ when doing regex validation. That happens when the value is not a parsable string type.
- Checking that the value is a valid dict object is now done even if the mapping keyword is not specefied in the schema.
This makes that check more eager and errors can apear that previously was not there.
- Changed the sane default type if that key is not defined to be _str_. Before this, type had to be defined every time and the default type did not work as expected.
This is a major change and can cause validation to either fail or to stop failing depending on the case.
- Changed validation for if a value is required and a value in a list for example is _None_. It now adds a normal validation errors instead of raising a _CoreError_.
- Value for keyword _desc_ now _MUST_ be a string or a _RuleError_ will be raised.
- Value for keyword _example_ now _MUST_ be a string or a _RuleError_ will be raised.
- Value for keyword _name_ now _MUST_ be a string or a _RuleError_ will be raised.

General changes:
- Ported alot of testcases directly from _Kwalify_ test data (_test-validator.yaml -> 30f.yaml & 43s.yaml_) so that this lib can have greater confidence that rules is implemented in the same way as _Kwalify_.
- Refactored _test_core_files_ method to now accept test files with multiple of documents. The method now tries to read all documents from each test file and run each document seperatly.
It now alos reports more detailed about what file and document that fails the test to make it easier to track down problems.
- Major refactoring of test files to now be grouped based on what they are testing instead of a increased counter that do not represent anything.
It will be easier to find out what keywords lack tests and what keywords that have enough tests.

1.5.2

- Convert all documentation to readthedocs
- True/False is no longer considered valid integer
- python3 'bytes' objects is now a valid strings and text type
- The regular PyYaml support is now deprecated in favor of ruamel.yaml, see the following link for more details about
PyYaml being deprecated https://bitbucket.org/xi/pyyaml/issues/59/has-this-project-been-abandoned
PyYaml will still be possible to use in the next major release version (1.6.0) but removed in release (1.7.0) and forward.
- ruamel.yaml is now possible to install with the following command for local development _pip install -e '.[ruamel]'_
and for production, use _pip install 'pykwalify[ruamel]'_
- ruamel.yaml is now used before PyYaml if installed on your system
- Fixed a bug where scalar type was not validated correctly.
- Unpin all dependencies but still maintain a minimum versions of each lib
- Allowed mixing of regex and normal keywords when matching a string (jmacarthur)

1.5.1

- Improvements to documentation (scottclowe).
- Improved code linting by reworking private variables in Rule class to now be properties and updated
all code that used the old way.
- Improved code linting by reworking all Log messages to render according to pep standard.
(By using %s and passing in variables as positional arguments)
- Fix bug when validating sequence and value should only be unicode escaped when a string
- Improve validation of timestamps.
- Improve float validation to now accept strings that is valid ints that uses scientific notation, "1e-06" for example.
- Update travis to test against python 3.6

1.5.0

- float / number type now support range restrictions
- ranges on non number types (e.g. seq, string) now need to be non negative.
- Fixed encoding bug triggered when both regex matching-rule 'any' and 'all' found keyword that
failed regex match. Added failure unit tests to cover regex matching-rule 'any' and 'all' during
failed regex match. Updated allowed rule list to include matching-rule 'all'.
- Changed _validate_mappings method from using re.match to re.search. This fixes bug related to
multiple keyword regex using matching-rule 'any'. Added success unit tests to test default, 'any',
and 'all' matching-rule.

1.4.1

- Added tests to sdist to enable downstream packaging to run tests. No code changes in this release.

1.4.0

- Dropped support for python 3.2 becuase of unicode literals do not exists in python 3.2.
- Fixed logging & raised exceptions when using unicode characters inside schemas/data/filenames.
- Reworked all RuleError exceptions to now have better exception messages.
- RuleError exceptions now have a unique 'error_key' that can make it easier to identify what error it is.
- Paths for RuleErrors have been moved inside the exception as a variable.
- Rewrote all SchemaConflict exceptions to be more human readable.

Page 2 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.