Skip to content

Commit

Permalink
Merge pull request #2535 from fishtown-analytics/feature/allow-packag…
Browse files Browse the repository at this point in the history
…e-version-floats

allow floats for package versions, add a test with a float-like branch (#2518)
  • Loading branch information
beckjake authored Jun 15, 2020
2 parents 0be8326 + 0beb03f commit b9053a2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Fixes
- dbt compile and ls no longer create schemas if they don't already exist ([#2525](https://github.com/fishtown-analytics/dbt/issues/2525), [#2528](https://github.com/fishtown-analytics/dbt/pull/2528))
- `dbt deps` now respects the `--project-dir` flag, so using `dbt deps --project-dir=/some/path` and then `dbt run --project-dir=/some/path` will properly find dependencies ([#2519](https://github.com/fishtown-analytics/dbt/issues/2519), [#2534](https://github.com/fishtown-analytics/dbt/pull/2534))
- `packages.yml` revision/version fields can be float-like again (`revision: '1.0'` is valid). ([#2518](https://github.com/fishtown-analytics/dbt/issues/2518), [#2535](https://github.com/fishtown-analytics/dbt/pull/2535))

## dbt 0.17.0 (June 08, 2020)

Expand Down
20 changes: 18 additions & 2 deletions core/dbt/contracts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/deps/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions core/dbt/deps/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
]
}
Expand Down

0 comments on commit b9053a2

Please sign in to comment.