Giter Club home page Giter Club logo

socless_python's People

Contributors

a-gray-cat avatar mureinik avatar noxasaxon avatar twilioyuezhu avatar ubaniabalogun avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

socless_python's Issues

Templating Engine casts stringified numbers to number when resolving parameters

What's Happening

When resolving a stringified number as a parameter, the template engine converts the stringified number into an actual number type. For example, given the context object

{
"signups": "100"
}

and parameter map

{
"attendees": "{{context.signups}}"
}

The returned resolved parameter object is a number type..

{
"attendees": 100
}

instead of a string

{
"attendees": "100"
}

What's expected

The expectation is that resolving a stringified number will return a the original strigified number without casting it to a number type (i.e integer or float)

How to recreate

from socless.paramresolver import ParameterResolver

context = {"signups": "100"}
resolver = ParameterResolver(context)
params = {"attendees": "{{context.signups}}"}
expected = {"attendees": "100"}

# This should throw an assertion error
assert resolver.resolve_parameters(params) == expected, "Parameter Resolver not returning expected object"

Additional notes

Adding single quotes around the template string prevents the stringified number from being cast to a number type. As an example, the below yields the correct response (note the additional single-quotes)

{
"attendees": "'{{context.signups}}'"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.