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

Remove functions from __init__.py that don't belong there #503

Merged
merged 3 commits into from Jul 18, 2017

Conversation

Projects
None yet
3 participants
@jeremycline
Copy link
Member

jeremycline commented Jul 11, 2017

Anitya suffers from very circular imports. These are caused by defining
inter-dependent functions in various __init__.py. These modules are
for package initialization. This moves all the code from
anitya/__init__.py and anitya/lib/__init__.py into
anitya/lib/utilities.py (not a great name, but most of the functions
inside it need to be factored out so I don't expect it to remain for too
long).

This should make working on the backend much less painful since it can
now import anitya.config without causing the entire backend to be
imported before the configuration can be imported.

Signed-off-by: Jeremy Cline jeremy@jcline.org

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Jul 11, 2017

Codecov Report

Merging #503 into master will increase coverage by 0.36%.
The diff coverage is 83.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #503      +/-   ##
==========================================
+ Coverage   85.48%   85.84%   +0.36%     
==========================================
  Files          50       51       +1     
  Lines        2383     2367      -16     
  Branches      315      313       -2     
==========================================
- Hits         2037     2032       -5     
+ Misses        275      264      -11     
  Partials       71       71
Impacted Files Coverage Δ
anitya/api.py 87.87% <100%> (+0.09%) ⬆️
anitya/app.py 77.5% <100%> (+0.28%) ⬆️
anitya/api_v2.py 100% <100%> (ø) ⬆️
anitya/ui.py 69.04% <71.42%> (+0.1%) ⬆️
anitya/admin.py 77.05% <75%> (+0.09%) ⬆️
anitya/lib/utilities.py 83.51% <83.51%> (ø)
anitya/tests/lib/backends/__init__.py 100% <0%> (+20%) ⬆️
anitya/tests/lib/__init__.py 100% <0%> (+20.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c4a191...74bab64. Read the comment docs.

distro=distro,
description=final_msg)

return final_msg

This comment has been minimized.

@bowlofeggs

bowlofeggs Jul 11, 2017

Are we confident that third party programs wouldn't be importing these from here? Some of them were named with an underscore, but some were not. If we aren't sure, should we import those things here so they can still be imported? Or maybe bump the X version?

This comment has been minimized.

@jeremycline

jeremycline Jul 11, 2017

Member

Nope, this breaks APIs, but there's not a good way around it. We're still versioned 0.y.z and I intend that to mean its API is not stable. There are going to be further breakages as I untangle the modules, unfortunately.

I'll make nice release notes about it, though.

@@ -0,0 +1,508 @@
# -*- coding: utf-8 -*-

This comment has been minimized.

@bowlofeggs

bowlofeggs Jul 11, 2017

The project doesn't seem to have an overall copyright claim. I recommend claiming copyright on this file (and I recommend correcting this for the rest of the project too). Don't forget that this code came from existing files, so the copyright claim should take the history of those files into account for ownership and dates.

@jeremycline jeremycline force-pushed the jeremycline:no-more-init-for-code branch from 133d32d to 4efa5f4 Jul 11, 2017

jeremycline added some commits Jul 11, 2017

Remove functions from __init__.py that don't belong there
Anitya suffers from very circular imports. These are caused by defining
inter-dependent functions in various ``__init__.py``. These modules are
for package initialization. This moves all the code from
``anitya/__init__.py`` and ``anitya/lib/__init__.py`` into
``anitya/lib/utilities.py`` (not a great name, but most of the functions
inside it need to be factored out so I don't expect it to remain for too
long).

This should make working on the backend much less painful since it can
now import ``anitya.config`` without causing the entire backend to be
imported before the configuration can be imported.

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Move the tests for anitya/lib/utilities.py into a module
Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Add changelog entry for #503
Signed-off-by: Jeremy Cline <jeremy@jcline.org>

@jeremycline jeremycline force-pushed the jeremycline:no-more-init-for-code branch from 4efa5f4 to 74bab64 Jul 11, 2017

@jeremycline

This comment has been minimized.

Copy link
Member

jeremycline commented Jul 11, 2017

Okay, the copyright claim has been fixed and I wrote some release notes. I'd appreciate it if you cast your eye over the notes to see if they're nice enough.

@bowlofeggs

This comment has been minimized.

Copy link

bowlofeggs commented Jul 11, 2017

@jeremycline jeremycline merged commit b748561 into release-monitoring:master Jul 18, 2017

2 of 3 checks passed

codecov/patch 83.56% of diff hit (target 85.48%)
Details
codecov/project 85.84% (+0.36%) compared to 5c4a191
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jeremycline jeremycline deleted the jeremycline:no-more-init-for-code branch Jul 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment