[jira] [Commented] (AVRO-2183) Nameless schema should raise AttributeError when attempting to access name

2018-11-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AVRO-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682287#comment-16682287
 ] 

ASF GitHub Bot commented on AVRO-2183:
--

Fokko closed pull request #313: AVRO-2183 Provide name only for named schema
URL: https://github.com/apache/avro/pull/313
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lang/py3/avro/schema.py b/lang/py3/avro/schema.py
index 0ebd41ffc..2fc7302d1 100644
--- a/lang/py3/avro/schema.py
+++ b/lang/py3/avro/schema.py
@@ -183,18 +183,6 @@ def __init__(self, type, other_props=None):
 if other_props:
   self._props.update(other_props)
 
-  @property
-  def name(self):
-"""Returns: the simple name of this schema."""
-return self._props['name']
-
-  @property
-  def fullname(self):
-"""Returns: the fully qualified name of this schema."""
-# By default, the full name is the simple name.
-# Named schemas override this behavior to include the namespace.
-return self.name
-
   @property
   def namespace(self):
 """Returns: the namespace this schema belongs to, if any, or None."""
@@ -625,6 +613,12 @@ def name(self):
 # The name of a primitive type is the type itself.
 return self.type
 
+  @property
+  def fullname(self):
+"""Returns: the fully qualified name of this schema."""
+# The full name is the simple name for primitive schema.
+return self.name
+
   def to_json(self, names=None):
 if len(self.props) == 1:
   return self.fullname
diff --git a/lang/py3/avro/tests/test_schema.py 
b/lang/py3/avro/tests/test_schema.py
index c83652886..fa7056747 100644
--- a/lang/py3/avro/tests/test_schema.py
+++ b/lang/py3/avro/tests/test_schema.py
@@ -472,6 +472,19 @@ def testCorrectRecursiveExtraction(self):
 # it could be reparsed.
 self.assertEqual("X", t.fields[0].type.name)
 
+  def testNoName(self):
+"""Test that schema without a name
+raise AttributeError when you try
+to access their name."""
+cases = [
+  '{"type": "array", "items": "int"}',
+  '{"type": "map", "values": "int"}',
+  '["null", "int"]',
+]
+for case in (schema.Parse(case) for case in cases):
+  self.assertRaises(AttributeError, lambda: case.name)
+  self.assertEqual(getattr(case, "name", "default"), "default")
+
   def testParse(self):
 correct = 0
 for iexample, example in enumerate(EXAMPLES):


 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Nameless schema should raise AttributeError when attempting to access name
> --
>
> Key: AVRO-2183
> URL: https://issues.apache.org/jira/browse/AVRO-2183
> Project: Apache Avro
>  Issue Type: Bug
>  Components: python
>Reporter: Michael A. Smith
>Priority: Major
>
> In the "py" implementation, this works as expected:
> {noformat}
> >>> from avro.schema import parse
> >>> s = parse('{"type": "array", "items": "int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> AttributeError: 'ArraySchema' object has no attribute 'name'{noformat}
> but in the py3 implementation, a {{NameError}} is raised instead:
> {noformat}
> >>> from avro.schema import Parse
> >>> s=Parse('{"type":"array","items":"int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> This behavior breaks several python idioms, including the ability to get a 
> default value using {{getattr}}:
> {noformat}
> >>> getattr(s, "name", "default")
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> I will open a PR with tests and a fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2183) Nameless schema should raise AttributeError when attempting to access name

2018-11-10 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/AVRO-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682288#comment-16682288
 ] 

ASF subversion and git services commented on AVRO-2183:
---

Commit ca1ef06d87424630f80ade31afcd8a1108dd5fed in avro's branch 
refs/heads/master from [~kojiro]
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=ca1ef06 ]

AVRO-2183 Provide name only for named schema (#313)

Otherwise, allow python to raise an AttributeError

> Nameless schema should raise AttributeError when attempting to access name
> --
>
> Key: AVRO-2183
> URL: https://issues.apache.org/jira/browse/AVRO-2183
> Project: Apache Avro
>  Issue Type: Bug
>  Components: python
>Reporter: Michael A. Smith
>Priority: Major
>
> In the "py" implementation, this works as expected:
> {noformat}
> >>> from avro.schema import parse
> >>> s = parse('{"type": "array", "items": "int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> AttributeError: 'ArraySchema' object has no attribute 'name'{noformat}
> but in the py3 implementation, a {{NameError}} is raised instead:
> {noformat}
> >>> from avro.schema import Parse
> >>> s=Parse('{"type":"array","items":"int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> This behavior breaks several python idioms, including the ability to get a 
> default value using {{getattr}}:
> {noformat}
> >>> getattr(s, "name", "default")
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> I will open a PR with tests and a fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2183) Nameless schema should raise AttributeError when attempting to access name

2018-11-09 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AVRO-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16681676#comment-16681676
 ] 

ASF GitHub Bot commented on AVRO-2183:
--

cutting commented on issue #313: AVRO-2183 Provide name only for named schema
URL: https://github.com/apache/avro/pull/313#issuecomment-437415763
 
 
   Looks reasonable to me, but I'm not a Python guy.
   
   Does anyone see a problem with this?  If, no one speaks up, let's commit it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Nameless schema should raise AttributeError when attempting to access name
> --
>
> Key: AVRO-2183
> URL: https://issues.apache.org/jira/browse/AVRO-2183
> Project: Apache Avro
>  Issue Type: Bug
>  Components: python
>Reporter: Michael A. Smith
>Priority: Major
>
> In the "py" implementation, this works as expected:
> {noformat}
> >>> from avro.schema import parse
> >>> s = parse('{"type": "array", "items": "int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> AttributeError: 'ArraySchema' object has no attribute 'name'{noformat}
> but in the py3 implementation, a {{NameError}} is raised instead:
> {noformat}
> >>> from avro.schema import Parse
> >>> s=Parse('{"type":"array","items":"int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> This behavior breaks several python idioms, including the ability to get a 
> default value using {{getattr}}:
> {noformat}
> >>> getattr(s, "name", "default")
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> I will open a PR with tests and a fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2183) Nameless schema should raise AttributeError when attempting to access name

2018-11-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AVRO-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16680694#comment-16680694
 ] 

ASF GitHub Bot commented on AVRO-2183:
--

kojiromike commented on issue #313: AVRO-2183 Provide name only for named schema
URL: https://github.com/apache/avro/pull/313#issuecomment-437213684
 
 
   @Fokko @cutting Would one of you be able to take a look at this one, please?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Nameless schema should raise AttributeError when attempting to access name
> --
>
> Key: AVRO-2183
> URL: https://issues.apache.org/jira/browse/AVRO-2183
> Project: Apache Avro
>  Issue Type: Bug
>  Components: python
>Reporter: Michael A. Smith
>Priority: Major
>
> In the "py" implementation, this works as expected:
> {noformat}
> >>> from avro.schema import parse
> >>> s = parse('{"type": "array", "items": "int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> AttributeError: 'ArraySchema' object has no attribute 'name'{noformat}
> but in the py3 implementation, a {{NameError}} is raised instead:
> {noformat}
> >>> from avro.schema import Parse
> >>> s=Parse('{"type":"array","items":"int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> This behavior breaks several python idioms, including the ability to get a 
> default value using {{getattr}}:
> {noformat}
> >>> getattr(s, "name", "default")
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> I will open a PR with tests and a fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2183) Nameless schema should raise AttributeError when attempting to access name

2018-10-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AVRO-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16670139#comment-16670139
 ] 

ASF GitHub Bot commented on AVRO-2183:
--

kojiromike commented on issue #313: AVRO-2183 Provide name only for named schema
URL: https://github.com/apache/avro/pull/313#issuecomment-434697188
 
 
   bump


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Nameless schema should raise AttributeError when attempting to access name
> --
>
> Key: AVRO-2183
> URL: https://issues.apache.org/jira/browse/AVRO-2183
> Project: Avro
>  Issue Type: Bug
>  Components: python
>Reporter: Michael A. Smith
>Priority: Major
>
> In the "py" implementation, this works as expected:
> {noformat}
> >>> from avro.schema import parse
> >>> s = parse('{"type": "array", "items": "int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> AttributeError: 'ArraySchema' object has no attribute 'name'{noformat}
> but in the py3 implementation, a {{NameError}} is raised instead:
> {noformat}
> >>> from avro.schema import Parse
> >>> s=Parse('{"type":"array","items":"int"}')
> >>> s.name
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> This behavior breaks several python idioms, including the ability to get a 
> default value using {{getattr}}:
> {noformat}
> >>> getattr(s, "name", "default")
> Traceback (most recent call last):
> File "", line 1, in 
> File "/home/michaels/dev/avro/lang/py3/avro/schema.py", line 224, in name
> return self._props['name']
> KeyError: 'name'{noformat}
> I will open a PR with tests and a fix.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)