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

Optional arguments in environs implementation methods #741

Open
knutnergaard opened this issue Aug 14, 2024 · 4 comments
Open

Optional arguments in environs implementation methods #741

knutnergaard opened this issue Aug 14, 2024 · 4 comments

Comments

@knutnergaard
Copy link
Contributor

knutnergaard commented Aug 14, 2024

Ref. this post:

No, sorry for not bing clear. The kwargs is very logical. I'm alluding to name being optional in the public method, but not in the private one.

Ah. This is also intentional. There shouldn’t be any optional arguments in the environment implementation methods. I can’t swear that there aren’t some now, but my intention at the start was that everything arriving to the environment methods would be defined and of the correct type. This way, any type conversion and defaults are handled at the generic fontParts level and this behavior will thus be consistent across implementations. It also alleviates a ton of work in the subclasses because all the type testing and conversion is a lot of redundant code. I was looking to see if I had written any notes about this and I found this in the documentation that might be helpful.

Originally posted by @typesupply in #207 (comment)

There are indeed a few cases of default values in the environment implementation of methods. If desired, I can convert them to be absolute as I come across them while implementing the type annotation and working on the docs.

Also, when running mypy, there will be a conflict between the public and private methods whenever one employs optional values and the other does not. The best thing, unless you want to ignore this, is to implement a conditional to eliminate the possibility of None wherever it's incompatible. I can do this too if you wish.

@knutnergaard knutnergaard mentioned this issue Aug 16, 2024
@benkiel
Copy link
Member

benkiel commented Aug 21, 2024

Yes, please do both of these things!

@knutnergaard
Copy link
Contributor Author

@benkiel, the BaseGlyph class has a few cases where default None values in the environment implementation method are actually documented in the docstring (e.g., in the _appendGuideline method). Can you confirm that these also should be absolute?

@benkiel
Copy link
Member

benkiel commented Sep 19, 2024

Hey @knutnergaard I'm unsure what you mean by absolute in this context, could you elaborate?

@knutnergaard
Copy link
Contributor Author

knutnergaard commented Sep 19, 2024

Hey @knutnergaard I'm unsure what you mean by absolute in this context, could you elaborate?

@benkiel, sorry, absolute is probably not the right word. I simply mean mandatory or non-optional.

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

No branches or pull requests

2 participants