-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update classifications to operate using enums #113
base: main
Are you sure you want to change the base?
Conversation
Quite nicely the
See 72548cd |
…gender instead of strings.
…ired enum functionalities.
…tuitive naming, e.g. AGE_50_PLUS instead of P50. Also moves U18 to UNDER_18 etc. for consistency.
Update so that the Not the prettiest as it adds verbosity, duplicates 'age' ( Also moves junior age groups from |
All test failures at this point are A question here is whether to coax bowstyles into something that passes (as was previously the case) or make this a new error? I am erring on making it a new error. I am open to thoughts/discussions on this, however, if you have opinions @TomHall2020, @mjtamlyn, or @LiamPattinson (or other users)? |
Personally I'd like to be more forgiving, or at least have an option to. Perhaps a The use case for me upstream would be providing "unofficial" classifications. Ie show the user if their round was EMB standard, even if it wasn't an official round. Its then up to me and my UI to make it clear that it's not a real EMB score. An alternative would be exposing separate functions for converting a handicap to a classification, and another for validating the classification against the round and category limitations. Apologies I haven't been on this much, its all somehow gotten quite hectic recently |
Note to self - could have functions Options would be to:
|
mypy is sad with No fix despite being open for 2 years. |
Captures invalid ages and bowstyles as inputs to classification calculations and coaxes them into a valid format based on ArcheryGB rules. Not applied by default in code but can be used by user to return a dict that can be unpacked directly into the classification functions. Also includes tests for this functionality.
…ll need updating to require next stable release version (suggested to be March 2025).
Mypy can be made less sad by installing directly from git which contains a bugfix for the @TomHall2020 I have added a set of "coaxing" functions that can be used to turn an "invalid" group into a valid one as per the previous rules. The nice thing about how I wrote this is that it returns a |
This PR updates the classification routines to use enums (Flag) for age, bowstyle, and gender instead of strings.
This should partly address #112
By using Flag enums we restrict the format to a single type of input.
These are easier to handle, allowing a chunk of string handling code to be removed.
It also allows options to be made clear to the user, rather than having to guess or look at the function definitions in the source.
This is still WIP and some things I am not happy with:
It cannot start with a number or contain a
+
which presents an issue around clarity.Currently I use
P50
but I do not like this. I also don't wantO50
forO/0
issues and because the category is "50 and over", not "over 50".By this I mean that where previously inappropriate ages or bowstyles would be coerced to something e.g. Flatbow becomes Barebow for target, this is no longer the case. This is why some tests are currently failing.
Whilst I feel this is perhaps more "expected" behaviour - following the AGB rules - my external applications made use of this feature and will now need to handle this coercion themselves at a higher level.
I am still unsure what the best thing to do here would be.
Other things to handle #112:
Round
rather than a string.Other Notes:
Iteration over a
This is resolved withFlag
enum requires python>=3.11
which means we need to drop support for3.10
3.10
is in security phase and will not reach EoL until October 2026.aenum
in older versions.