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

Clarify expression alias logic #110

Closed

Conversation

evanpurkhiser
Copy link
Contributor

Instead of using tuple indexing use a namedtuple mapped from the expression aliases. This makes readability / understanding of this logic a little easier.

ExpressionAlias = namedtuple('ExpressionAlias', 'regular, hashed')

# Non-standard expression aliases
EXPR_ALIASES = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also pulls this up into the module scope so we're not redeclaring this mapping every time

Copy link
Owner

Choose a reason for hiding this comment

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

moving the aliases top module level would be ok, but not in favor of a namedtuple because users shall be allowed to update easily the aliases.

Another problem is that this change is not at all retrocompatible. To allow retrocompat, maybe using a class attribute that dictcopy the module level one would be a solution.

Copy link
Owner

Choose a reason for hiding this comment

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

Damn, the above comment was not validated, so you didnt saw it... sorry :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

users shall be allowed to update easily the aliases.

What makes it difficult to update the aliases because we're using a named tuple? Could you share an example of what you're thinking that is more difficult?

Copy link
Owner

Choose a reason for hiding this comment

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

dict are mutable, not namedtuple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You could just replace it like this though right

# Replace alias with whatever you want
EXPR_ALIASES['@midnight'] = ExpressionAlias("1 2 * * *", "h h * * *")

@evanpurkhiser
Copy link
Contributor Author

Updated to fix remove the conflict

@kiorky
Copy link
Owner

kiorky commented Oct 30, 2024

Updated to fix remove the conflict

oups, the other pr i just merged broke it again :( :) .

@evanpurkhiser
Copy link
Contributor Author

I'll get it fixed after I get the black formatting done :)

Instead of using tuple indexing use a namedtuple mapped from the
expression aliases. This makes readability / understanding of this logic
a little easier.
@evanpurkhiser
Copy link
Contributor Author

Going to close this one out since this one's a bit controversial.

Feel free to pull from parts of it though if you'd like!

@evanpurkhiser evanpurkhiser deleted the simplify-expr-alises branch November 18, 2024 23:29
@kiorky
Copy link
Owner

kiorky commented Nov 19, 2024

Going to close this one out since this one's a bit controversial.

Feel free to pull from parts of it though if you'd like!

When i started to review #136 & & #135, what i saw is that it will be hard for someone else to do the relevant changes and so i started to do it myself as some spaghetti code that needs to be removed to implement clearly DST :-/.

TBH, i though i could finish DST rework, i have NOW a large diff which is on the go locally, but is not finished yet.

I hope to finish that soon with a better state that it is now.

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