Repository: sympy/sympy
Pull request: Remove reference to Python2 in round
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
I believe this fixes #16686

#### Brief description of what is fixed or changed


#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
NO ENTRY
<!-- END RELEASE NOTES -->

Problem statement:
remove Py2 code from `round` when dropping Python 2 support
The Notes section and two places in Expr.round (with inlines about Py2) need to be changed when Python 2 support is dropped. In the first case, all the rounding semantics can be handled by builtin `round` instead of the Expr.round code that follows in the if-block; in the second, the handling can be done in terms of `int` through `round` instead of through `Expr.round`.

Hints from issue discussion:

Commit message: Remove reference to Python2 in round

Patch to review:
diff --git a/sympy/core/expr.py b/sympy/core/expr.py
index bd3cf4e36cbb..e3a71c74ac96 100644
--- a/sympy/core/expr.py
+++ b/sympy/core/expr.py
@@ -3641,17 +3641,8 @@ def round(self, n=None):
         Notes
         =====
 
-        The Python builtin function, round, always returns a
-        float in Python 2 while the SymPy round method (and
-        round with a Number argument in Python 3) returns a
-        Number.
-
-        >>> from sympy.core.compatibility import PY3
-        >>> isinstance(round(S(123), -2), Number if PY3 else float)
-        True
-
-        For a consistent behavior, and Python 3 rounding
-        rules, import `round` from sympy.core.compatibility.
+        When applied to a Number, `round` will return a Number, not a Python
+        float or int:
 
         >>> isinstance(round(S(123), -2), Number)
         True
@@ -3670,11 +3661,10 @@ def round(self, n=None):
             return x
         if not x.is_extended_real:
             i, r = x.as_real_imag()
-            return i.round(n) + S.ImaginaryUnit*r.round(n)
+            return round(i, n) + S.ImaginaryUnit*round(r, n)
         if not x:
             return S.Zero if n is None else x
 
-
         p = as_int(n or 0)
 
         if x.is_Integer:


Code review comments:
diff_hunk: @@ -3641,17 +3641,8 @@ def round(self, n=None):
         Notes
         =====
 
-        The Python builtin function, round, always returns a
-        float in Python 2 while the SymPy round method (and
-        round with a Number argument in Python 3) returns a
-        Number.
-
-        >>> from sympy.core.compatibility import PY3
-        >>> isinstance(round(S(123), -2), Number if PY3 else float)
-        True
-
-        For a consistent behavior, and Python 3 rounding
-        rules, import `round` from sympy.core.compatibility.
+        When applied to a Number, `round` will return a Number, not a Python
path: sympy/core/expr.py
text: @user1:
I think this whole note should be removed. I would automatically expect every SymPy function to return a SymPy type, which is all that this says now. 

@user2:
`round` is a Python builtin -- that's why this note is added. It let's the user know that SymPy has defined a method call be `round` so a SymPy Number (not Python number) is returned:
```python
>>> type(round)
<type 'builtin_function_or_method'>
```