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

🧹 Upgrade syntax to py310 using pyupgrade #1162

Merged
merged 5 commits into from
Nov 5, 2022

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Nov 5, 2022

Since we upgraded to py310+ we can also make use of the syntax improvements.
The changes are made by simply telling pyupgrade that we use python 3.10+ syntax in .pre-commit-config.yaml

Change summary

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 🚧 Added changes to changelog (mandatory for all PR's)

@s-weigand s-weigand requested review from jsnel, joernweissenborn and a team as code owners November 5, 2022 00:41
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2022

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran/py310-upgrade

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2022

Benchmark is done. Checkout the benchmark result page.
Benchmark differences below 5% might be due to CI noise.

Benchmark diff v0.6.0 vs. main

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [6c3c390e]       [db1e5760]
     <v0.6.0>                   
!        67.9±3ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
!        137±40ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
!        68.0±3ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
!       86.3±40ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
!        83.3±2ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
!       94.2±40ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
!        89.5±6ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
!        159±40ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             201M             207M     1.03  IntegrationTwoDatasets.peakmem_optimize
-      2.23±0.02s       1.57±0.05s     0.70  IntegrationTwoDatasets.time_optimize

Benchmark diff main vs. PR

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [db1e5760]       [20e469f9]
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             207M             208M     1.00  IntegrationTwoDatasets.peakmem_optimize
       1.57±0.05s       1.61±0.06s     1.03  IntegrationTwoDatasets.time_optimize

@codecov
Copy link

codecov bot commented Nov 5, 2022

Codecov Report

Base: 87.6% // Head: 87.5% // Decreases project coverage by -0.0% ⚠️

Coverage data is based on head (7780c56) compared to base (ad3d44b).
Patch coverage: 100.0% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1162     +/-   ##
=======================================
- Coverage   87.6%   87.5%   -0.1%     
=======================================
  Files        103     103             
  Lines       4899    4895      -4     
  Branches     807     806      -1     
=======================================
- Hits        4292    4288      -4     
  Misses       489     489             
  Partials     118     118             
Impacted Files Coverage Δ
glotaran/builtin/io/yml/utils.py 100.0% <ø> (ø)
glotaran/cli/commands/optimize.py 24.2% <ø> (-1.2%) ⬇️
glotaran/deprecation/modules/builtin_io_yml.py 100.0% <ø> (ø)
glotaran/io/interface.py 100.0% <ø> (ø)
glotaran/io/prepare_dataset.py 65.3% <ø> (ø)
glotaran/plugin_system/base_registry.py 100.0% <ø> (ø)
glotaran/plugin_system/data_io_registration.py 97.2% <ø> (ø)
glotaran/plugin_system/project_io_registration.py 100.0% <ø> (ø)
glotaran/project/dataclass_helpers.py 83.8% <ø> (ø)
glotaran/project/result.py 90.9% <ø> (-0.1%) ⬇️
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 5, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.03%.

Quality metrics Before After Change
Complexity 3.89 ⭐ 3.88 ⭐ -0.01 👍
Method Length 56.47 ⭐ 56.65 ⭐ 0.18 👎
Working memory 6.30 🙂 6.30 🙂 0.00
Quality 76.73% 76.76% 0.03% 👍
Other metrics Before After Change
Lines 7456 7451 -5
Changed files Quality Before Quality After Quality Change
glotaran/builtin/io/yml/utils.py 83.39% ⭐ 83.36% ⭐ -0.03% 👎
glotaran/builtin/io/yml/test/test_model_parser.py 79.28% ⭐ 79.31% ⭐ 0.03% 👍
glotaran/cli/commands/optimize.py 14.98% ⛔ 14.98% ⛔ 0.00%
glotaran/cli/commands/util.py 74.22% 🙂 74.22% 🙂 0.00%
glotaran/deprecation/deprecation_utils.py 66.67% 🙂 66.99% 🙂 0.32% 👍
glotaran/deprecation/modules/builtin_io_yml.py 60.07% 🙂 60.06% 🙂 -0.01% 👎
glotaran/deprecation/modules/test/init.py 72.69% 🙂 72.61% 🙂 -0.08% 👎
glotaran/deprecation/test/test_deprecation_utils.py 86.50% ⭐ 86.48% ⭐ -0.02% 👎
glotaran/io/interface.py 88.29% ⭐ 88.22% ⭐ -0.07% 👎
glotaran/io/prepare_dataset.py 65.77% 🙂 65.64% 🙂 -0.13% 👎
glotaran/model/dataset_model.py 79.23% ⭐ 79.23% ⭐ 0.00%
glotaran/model/megacomplex.py 89.75% ⭐ 89.74% ⭐ -0.01% 👎
glotaran/model/model.py 77.51% ⭐ 77.55% ⭐ 0.04% 👍
glotaran/parameter/parameters.py 71.42% 🙂 71.42% 🙂 0.00%
glotaran/plugin_system/base_registry.py 76.32% ⭐ 76.52% ⭐ 0.20% 👍
glotaran/plugin_system/data_io_registration.py 80.26% ⭐ 80.25% ⭐ -0.01% 👎
glotaran/plugin_system/io_plugin_utils.py 80.63% ⭐ 80.57% ⭐ -0.06% 👎
glotaran/plugin_system/project_io_registration.py 80.01% ⭐ 80.01% ⭐ 0.00%
glotaran/plugin_system/test/test_base_registry.py 91.43% ⭐ 91.43% ⭐ 0.00%
glotaran/plugin_system/test/test_project_io_registration.py 87.88% ⭐ 87.88% ⭐ 0.00%
glotaran/project/dataclass_helpers.py 58.46% 🙂 58.45% 🙂 -0.01% 👎
glotaran/project/project_registry.py 89.31% ⭐ 89.31% ⭐ 0.00%
glotaran/project/result.py 71.83% 🙂 71.83% 🙂 0.00%
glotaran/project/scheme.py 93.37% ⭐ 93.34% ⭐ -0.03% 👎
glotaran/project/generators/generator.py 76.61% ⭐ 76.61% ⭐ 0.00%
glotaran/testing/plugin_system.py 84.01% ⭐ 84.03% ⭐ 0.02% 👍
glotaran/typing/protocols.py 82.52% ⭐ 81.59% ⭐ -0.93% 👎
glotaran/typing/types.py 80.13% ⭐ 79.52% ⭐ -0.61% 👎
glotaran/utils/io.py 74.45% 🙂 74.45% 🙂 0.00%

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
glotaran/cli/commands/optimize.py optimize_cmd 29 😞 572 ⛔ 19 ⛔ 14.98% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
glotaran/project/result.py Result.markdown 10 🙂 242 ⛔ 14 😞 39.37% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/project/dataclass_helpers.py asdict 18 🙂 142 😞 13 😞 42.15% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/utils/io.py _load_datasets 15 🙂 176 😞 12 😞 42.69% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/deprecation/deprecation_utils.py deprecate_dict_entry 11 🙂 154 😞 14 😞 45.27% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@s-weigand
Copy link
Member Author

Nice we also had sourcery trigger ^^

jsnel
jsnel previously approved these changes Nov 5, 2022
Avoid Duplicated Lines (%) false positives until SonarCloud is intelligent enough to avoid imports in Python files.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jsnel jsnel merged commit d912b5d into glotaran:main Nov 5, 2022
@jsnel jsnel deleted the py310-upgrade branch November 5, 2022 22:28
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