Repository: dbt-labs/dbt-core

Issue:
Allow floats in package version fields
### Describe the feature
A lot of existing packages have versions like `'1.0'`. In native env rendering, this becomes `1.0`, which is a float, and that fails validation. The workaround is to use `"{{ 1.0 | as_text }}"`, which people hate. We should just allow users to supply floats for git revisions/package versions and then convert them to strings internally when before doing version-y things.

### Describe alternatives you've considered
Tell people to use `{{ 1.0 | as_text }}`, over and over again.

### Additional context
There are other fields, but probably none as egregious as this one.

### Who will this benefit?
End users of packages.



Discussion:

Resolving patch:
diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py
--- a/core/dbt/contracts/project.py
+++ b/core/dbt/contracts/project.py
@@ -48,17 +48,33 @@ class LocalPackage(Package):
     local: str
 
 
+# `float` also allows `int`, according to PEP484 (and jsonschema!)
+RawVersion = Union[str, float]
+
+
 @dataclass
 class GitPackage(Package):
     git: str
-    revision: Optional[str]
+    revision: Optional[RawVersion]
     warn_unpinned: Optional[bool] = None
 
+    def get_revisions(self) -> List[str]:
+        if self.revision is None:
+            return []
+        else:
+            return [str(self.revision)]
+
 
 @dataclass
 class RegistryPackage(Package):
     package: str
-    version: Union[str, List[str]]
+    version: Union[RawVersion, List[RawVersion]]
+
+    def get_versions(self) -> List[str]:
+        if isinstance(self.version, list):
+            return [str(v) for v in self.version]
+        else:
+            return [str(self.version)]
 
 
 PackageSpec = Union[LocalPackage, GitPackage, RegistryPackage]
diff --git a/core/dbt/deps/git.py b/core/dbt/deps/git.py
--- a/core/dbt/deps/git.py
+++ b/core/dbt/deps/git.py
@@ -105,7 +105,7 @@ def __init__(
     def from_contract(
         cls, contract: GitPackage
     ) -> 'GitUnpinnedPackage':
-        revisions = [contract.revision] if contract.revision else []
+        revisions = contract.get_revisions()
 
         # we want to map None -> True
         warn_unpinned = contract.warn_unpinned is not False
diff --git a/core/dbt/deps/registry.py b/core/dbt/deps/registry.py
--- a/core/dbt/deps/registry.py
+++ b/core/dbt/deps/registry.py
@@ -85,9 +85,7 @@ def _check_in_index(self):
     def from_contract(
         cls, contract: RegistryPackage
     ) -> 'RegistryUnpinnedPackage':
-        raw_version = contract.version
-        if isinstance(raw_version, str):
-            raw_version = [raw_version]
+        raw_version = contract.get_versions()
 
         versions = [
             semver.VersionSpecifier.from_version_string(v)


Test patch:
diff --git a/test/integration/006_simple_dependency_test/test_simple_dependency.py b/test/integration/006_simple_dependency_test/test_simple_dependency.py
--- a/test/integration/006_simple_dependency_test/test_simple_dependency.py
+++ b/test/integration/006_simple_dependency_test/test_simple_dependency.py
@@ -26,7 +26,7 @@ def packages_config(self):
             "packages": [
                 {
                     'git': 'https://github.com/fishtown-analytics/dbt-integration-project',
-                    'revision': 'dbt/0.17.0',
+                    'revision': '1.0',
                 }
             ]
         }