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

allow floats for package versions, add a test with a float-like branch (#2518) #2535

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know!

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