Skip to content

Conversation

@bernt-matthias
Copy link
Contributor

by checking for subclasses

by checking for subclasses
@multimeric
Copy link
Collaborator

This seems like a reasonable approach. I do have some feedback, however.

@multimeric
Copy link
Collaborator

Out of interest, what is an example of this PR improving behaviour? I would have though your example in #37 would predict None, then CliFile() then CliFile() respectively, and then return CliFile(). We only use subclasses for CliFileSystemType, and only recently, but the inference will never return CliFileSystemType, so it seems irrelevant.

If I ever rewrite my type system (and the representable property), I might be able to make this work better.


return infer_type(self.description) or cli_types.CliString()
tpe = None
tpe_cand = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer descriptive variable names where possible. typ and type_candidates please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would have though your example in #37 would predict None, then CliFile() then CliFile() respectively, and then return CliFile(). We only use subclasses for CliFileSystemType, and only recently, but the inference will never return CliFileSystemType, so it seems irrelevant.

True. I already forgot that we implemented the distinction between in/output files/dirs by properties and not subclasses.Then I will check for isinstance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah that makes more sense

Copy link
Collaborator

@multimeric multimeric left a comment

Choose a reason for hiding this comment

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

Could you please add a test case also please. You should be able to use the exact example from the linked issue.

@bernt-matthias
Copy link
Contributor Author

Could you please add a test case also please. You should be able to use the exact example from the linked issue.

Can try. Do you have an example how this is done? Or where?

since in/out file/dir is represented by properties of the same class

- also fixes linter errors
@multimeric
Copy link
Collaborator

Ah well eventually I'll make a test_data_model.py or something, but in the meantime I think you could chuck this into test_type_inference.py. You can construct a Flag() object with the fields that you mentioned in #37, and then assert that the value of Flag.get_type() returns the right value.

@multimeric
Copy link
Collaborator

Also look into getting pre-commit set-up so that the builds pass, and the git diffs are easier for me to read. You should just have to run:

pip install pre-commit
pre-commit install

Sign up for free to 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.

2 participants