Skip to content

Conversation

@apotterri
Copy link
Contributor

Both Django and Flask have two supported major versions. Fix validation
and update tests to reflect this.

Both Django and Flask have two supported major versions. Fix validation to reflect this.
Try to import appmap.django during initialization, to give us a chance to set up our middleware.
Copy link
Contributor

@dividedminddividedmind left a comment

Choose a reason for hiding this comment

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

Looks good, but note this changes the semantics and it's not clear to me this is intended. In particular, consider what happens when a dependency is detected with a major version different from any on the list of supported ones.

Comment on lines 27 to +43
dist_version=None
try:
dist_version=version(dist)
forvinversions:
try:
dist_version=version(dist)

required=parse(v)
actual=parse(dist_version)
ifrequired.major!=actual.major:
dist_version=None
continue

required=parse(v)
actual=parse(dist_version)
ifactual<required:
raiseValidationFailure(f'{dist} must have version >= {required}, found {actual}')

ifactual<required:
raiseValidationFailure(f'{dist} must have version >= {required}, found {actual}')
exceptPackageNotFoundError:
pass
returndist_version
exceptPackageNotFoundError:
dist_version=None
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: this changed logic is a bit convoluted and difficult to follow. How about something like:

try: dist_version=version(dist) actual=parse(dist_version) required=next(vforvinmap(parse, versions) ifv.major==actual.major) ifactual<required: raiseValidationFailureexceptPackageNotFoundError, StopIteration: returnNonereturndist_version

from . importdjango
exceptImportError:
# not using django
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems ok to me, python isn't as fragile re import order as ruby can be.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@apotterri@dividedmind