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

Config item passed with float with decimal in an integer field errors out #49

Open
micahjohnson150 opened this issue Mar 23, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@micahjohnson150
Copy link
Collaborator

  • inicheck version: 0.7.9
  • Python version: 3.6
  • Operating System: Linux

Description

Working with timesteps in Swiflow and found that a float passed to an integer item in the config file did not throw an inicheck error but rather an exception. This defeat the purpose of inicheck as we want to know all the errors that exist with a config file.

What I Did

config file

################################################################################
# Model Parameters
################################################################################

[model]
timestep_hours:                0.1

Master config entry:

[model]

timestep_hours:
default = 24,
type = int,
description = Timestep to march through time in integer hours

Fails with:

swiflow config.ini

and even with inicheck

inicheck -m swiflow -f config.ini

Traceback is

Traceback (most recent call last):
  File "/home/micahjohnson/projects/venv/swienv/bin/inicheck", line 8, in <module>
    sys.exit(main())
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/cli.py", line 65, in main
    changelog_file=args.changelog)
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/cli.py", line 108, in inicheck_main
    modules=modules, cli=True)
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/tools.py", line 252, in get_user_config
    ucfg = cast_all_variables(ucfg, mcfg)
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/tools.py", line 179, in cast_all_variables
    values = b.cast()
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/checkers.py", line 411, in cast
    result.append(self.type_func(v))
  File "/home/micahjohnson/projects/venv/swienv/lib/python3.6/site-packages/inicheck/checkers.py", line 591, in convert_to_int
    raise ValueError("Expecting integer and received float with "
ValueError: Expecting integer and received float with  non-zero decimal

@micahjohnson150 micahjohnson150 added the bug Something isn't working label Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant